shobhitjain Posted November 11, 2009 Share Posted November 11, 2009 Hi to all Professionals hereWell after lot of search and Discussion ,A question raised in my mindIf you have to send a cross domain request ,Keeping in mind all security and issues WHAT is the first thing that comes up in your mind?Also knowing that Javascript and Ajax doesn't allow this . Link to comment Share on other sites More sharing options...
Synook Posted November 11, 2009 Share Posted November 11, 2009 Server-side proxy? Link to comment Share on other sites More sharing options...
shobhitjain Posted November 11, 2009 Author Share Posted November 11, 2009 Will it work even if the file requesting is not on the localhost.Just like an application like toolbar. Link to comment Share on other sites More sharing options...
Synook Posted November 11, 2009 Share Posted November 11, 2009 The point of the proxy is so that the AJAX script doesn't have to directly request the remote server, instead, it requests the proxy sitting on the local server to make the request, on its behalf, to the remote destination, and return the response. So instead of AJAX script <-/-> Remote server you have AJAX script <---> server-side proxy <---> remote server And since the server-side script doesn't have the domain restrictions on it, it can request files from anywhere.I don't quite understand what you mean by "toolbar", though. Link to comment Share on other sites More sharing options...
shobhitjain Posted November 11, 2009 Author Share Posted November 11, 2009 Thanks for telling ,but i don't need any proxy.If proxy is needed the work would have been done long ago. I need to send request directly to server ,without any proxy,Like Application------------ Sends Request to-------------------->ServerApplication<------------Respond back to----------------------Server and all this to be done on cross domain....This is the exact problem Link to comment Share on other sites More sharing options...
thescientist Posted November 11, 2009 Share Posted November 11, 2009 I thought it's been mentioned that to request information cross-server, you need to use a server-side script, which essentially will act as a proxy.http://en.wikipedia.org/wiki/Proxy_server Link to comment Share on other sites More sharing options...
jeffman Posted November 11, 2009 Share Posted November 11, 2009 Forms do not have the same limitations as AJAX objects. I generally dislike iFrames, but you could duplicate the AJAX functionality you want by sending your request through a form in an invisible iFrame. (It could also be visible; that part does not matter.) Your whole page would not refresh; only the iFrame would refresh. You can then access the response that appears in the iFrame and do whatever you want with it.I would test the process with a visible iFrame just to make sure the technique works for you. (Remember that the true response will only be visible when you view source. This might make a difference if tabs and line breaks are significant.) Link to comment Share on other sites More sharing options...
Ingolme Posted November 11, 2009 Share Posted November 11, 2009 Forms do not have the same limitations as AJAX objects. I generally dislike iFrames, but you could duplicate the AJAX functionality you want by sending your request through a form in an invisible iFrame. (It could also be visible; that part does not matter.) Your whole page would not refresh; only the iFrame would refresh. You can then access the response that appears in the iFrame and do whatever you want with it.I would test the process with a visible iFrame just to make sure the technique works for you. (Remember that the true response will only be visible when you view source. This might make a difference if tabs and line breaks are significant.)You can send a request to an iframe, but you won't be able to read the content of the iframe with Javascript.The only way to receive information from another domain is through server-side scripting. And it really isn't that difficult. Link to comment Share on other sites More sharing options...
jeffman Posted November 11, 2009 Share Posted November 11, 2009 Oh, wait. You're saying that because the iFrame is loading a document from offsite, the browser won't let me use that technique. Duh. Link to comment Share on other sites More sharing options...
jeffman Posted November 11, 2009 Share Posted November 11, 2009 So why is the proxy solution not possible? Link to comment Share on other sites More sharing options...
Ingolme Posted November 11, 2009 Share Posted November 11, 2009 So why is the proxy solution not possible?Maybe he's confusing a "server-side proxy" with a "proxy server" and he doesn't want to use a proxy server. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 11, 2009 Share Posted November 11, 2009 If you can control what output the server sends back, then you can use a script tag proxy:http://jaybyjayfresh.com/2007/09/17/using-...-in-javascript/Or you can use a hidden iframe or a hidden form which submits to a hidden iframe:http://developer.apple.com/internet/webcontent/iframe.htmlYou could also have a Flash movie send out requests to the remote site and send the response to Javascript but, again, the remote server needs to explicitly allow that.If you cannot control what the remote server is doing, then your one option is to use a server-side proxy. Let me say that again: if you don't have control over what type of output the remote server will send, your only option is to use a server-side proxy. That is why we keep telling you to use a server-side proxy, but you don't seem like you want to believe us. Link to comment Share on other sites More sharing options...
jeffman Posted November 11, 2009 Share Posted November 11, 2009 Maybe he's confusing a "server-side proxy" with a "proxy server" and he doesn't want to use a proxy server.Ah. Yes, "proxy server" is not what we mean. I go through one at home to avoid my ISP's censoring software. It's slow and annoying. I wouldn't want to use one either.All we are describing is a script that runs on the server you're already using. I think Synook posted the basic code for a GET-to-POST version on another thread? Link to comment Share on other sites More sharing options...
Synook Posted November 11, 2009 Share Posted November 11, 2009 Maybe he doesn't want to use a server-side script?Or maybe he just wants to know whether it is technically possible with such a script? Link to comment Share on other sites More sharing options...
shobhitjain Posted November 12, 2009 Author Share Posted November 12, 2009 Sir ,everything is possible.I was just trying to see the working of OpenURL , so i couldn't reply last night,,,sorry for that.WellThe thing in most easiest manner is..you have an html page on hard-disk and a page on server like www.mysite.com/admin you have no proxy .no proxy web server nothing else.you clicked the button ,and the data is posted to the www......admin page..i can't explain my problem easier than this.While researching an open source toolbar like digg ,i found a command Openurl which does the same thing mentioned above,but it opens the page in other tab,which i don't wan't ,data must be posted in background.Also the server is in my control. Link to comment Share on other sites More sharing options...
Synook Posted November 12, 2009 Share Posted November 12, 2009 Well, if you have control over the remote server, then you can use XHR2 and make sure the server returns the correct headers. Of course, XHR2 isn't very widely supported yet, though. Some browsers also restrict the use of AJAX altogether for local pages.Have you thought about using a portable web server? Link to comment Share on other sites More sharing options...
shobhitjain Posted November 12, 2009 Author Share Posted November 12, 2009 using a web server (portable) means my extension of size 100kb will become 10,000kbWould you ever like to install a addon of about 10mB in firefox.I don't think so.you were talking about XHR2 ,Can you please elaborate it to me,,Would Firefox 3.5 support it.Please tell me Link to comment Share on other sites More sharing options...
Synook Posted November 12, 2009 Share Posted November 12, 2009 You are trying to write an XUL application? You could have told us that earlier :)And yes, I believe Firefox 3 and above support the XHR2 specification. Link to comment Share on other sites More sharing options...
shobhitjain Posted November 12, 2009 Author Share Posted November 12, 2009 Yes, i didn't mentioned it before because previously i was dependent on toolbar studio.Just today i coded whole of my toolbar in XUL ,so i mentioned the toolbar,But still this POSTing problem is not solved.You must have seen Delicious Bookmarklets ,I don't know ,how they do this thing.The data goes to server. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 12, 2009 Share Posted November 12, 2009 If you're making a toolbar then you probably have a whole set of things available to you that we haven't considered, I think we all assumed that you were just trying to make a web page that you double-click on to open and it sends an ajax request to another server. Regardless, if you have control over the server then you can use the script tag proxy technique:http://jaybyjayfresh.com/2007/09/17/using-...-in-javascript/ Link to comment Share on other sites More sharing options...
shobhitjain Posted November 13, 2009 Author Share Posted November 13, 2009 Thanks but if you have seen working of it,After getting loaded ,it sends request for only one time.Next time that button remains disabledSo it is of no use that we should make request only one time.The request should be made again and again Link to comment Share on other sites More sharing options...
shobhitjain Posted November 13, 2009 Author Share Posted November 13, 2009 Is there any Open Source Software which captures the selected data and Post it on the given url.....i might get help from there Link to comment Share on other sites More sharing options...
justsomeguy Posted November 13, 2009 Share Posted November 13, 2009 After getting loaded ,it sends request for only one time.Next time that button remains disabledI don't know what you're referring to, all of the techniques we've discussed can be used as many times as you want. There's no rule that you can only use something once.Is there any Open Source Software which captures the selected data and Post it on the given url.. like Firefox? Link to comment Share on other sites More sharing options...
shobhitjain Posted November 14, 2009 Author Share Posted November 14, 2009 You are right.May be my implementation was wrong.But one thing more ,i don't want to put this file on localhost.It worked as i put it onto localhost,But if it is on local drive ,It is even not sending the requests.No i was not talking about firefox.well leave that thing Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.