问题
I try to make a JQuery ajax request to 'http://pastebin.com/raw.php' and using this code:
$.ajax({
url: 'http://pastebin.com/raw.php',
data: "i=VJ29uFnk",
complete: function(jqXHR, textStatus) {
alert('complete');
},
success: function(data) {
alert(data);
},
error: function(xhr, status, error) {
alert('noh!')
}
});
With this I get a status '404' within xhr but the url I can see in firebug looks correct:
http://pastebin.com/raw.php?i=VJ29uFnk
Ideas?
回答1:
XHR calls are protected under the Same origin policy.
What you can do, however, is call a server side script that bypass this.
回答2:
You could circumvent the same origin policy by creating a php script that captured the data you want: example.com/getpage.php?url=pastebin.com/raw.php?i=VJ29uFnK
.
来源:https://stackoverflow.com/questions/16449492/jquery-ajax-request-to-http-pastebin-com-raw-php