开发者

Jquery Ajax in paste.kde.org

Hello there Iam trying to use the http://paste.kde.org api in order to make it work My code seems like

var p = {};
p.id=122083;
p.mode='json';

$.ajax({
url: 'http://paste.kde.org/show.php',
data: p,
success: function(data) {
   alert(data.result.id);
}

});

The output json is like :

{ "result": { "id": "122083", "author": "Anonymous", "timestamp开发者_Go百科": "1316135671", "language": "text", "data": "testing the app" } }

But I can;t make it work, also i have no alerts in the creation of the "pastes" although i can see them created in the paste.kde.org archive


I don't believe that paste.kde allows for ajax requests to their api. When attempting to run your code from jsfiddle, I got the following error:

XMLHttpRequest cannot load http://paste.kde.org/show.php?id=122083&mode=json. Origin http://fiddle.jshell.net is not allowed by Access-Control-Allow-Origin.

paste.kde.org would need to change their response headers to send the Access-Control-Allow-Origin header so that your ajax request could complete.

You could change your request so that your $.ajax call goes to your local server (let's say it's using PHP), and then you could run a curl request to the kde API, and then have your PHP script parrot back the results from paste.kde.org.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜