Skip to content Skip to sidebar Skip to footer

Cross-site Request

Should be done with the site number 1 request to the site number 2. Let the number one site will be localhost, and the site number 2 - the real server on the Internet. At site 2 th

Solution 1:

I'm assuming you mean with Ajax? You can't make cross-site domain requests through normal ajax due to the same origin policy. As such, a script hosted on localhost, can only make requests to localhost.

Now, you can get around this with JSONP, or JSON with padding. This allows you to append a script file to the dom from any source so the code can execute on your site. Personally, I've actually never used it and I understand you have to trust the origin of the script, you don't want arbitrary code being run on your site.

So in a nutshell, if you want localhost to make a request to 'site-2' you need to host a script on 'site-2' that gets loaded by your localhost and makes the request.

Solution 2:

After reading what brad just said, what i would do is to add another chain to the request.

I'll be calling a local serversidescript (cross domain proxy) that will request and process the data from the other server.

References

Post a Comment for "Cross-site Request"