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 there is 开发者_运维百科a file result.php, which takes GET-requests:
$var = @$_GET['q'] ;
$s = $_GET['s'] ;
$typefile = $_GET['type'];
How better to make a request? Can someone show me some examples to help? For 4 days I suffer, does not realize.
If somewhere is not clear written excuse my bad English with.
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.
After reading what brad just said, what i would do is to add another chain to the request.
I'll be calling a local serverside
script
(cross domain proxy) that will request and process the data from the other server.
References
- Cross-Domain Proxy
- Same Origin Policy
精彩评论