JQuery Ajax request to http://pastebin.com/raw.php

有些话、适合烂在心里 提交于 2019-12-11 06:33:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!