如何使Ajax和JQuery的跨站点脚本?脚本、站点、Ajax、JQuery

由网友(生死与你闯)分享简介:我是一个问题,我必须得到JSON从这里开始:i'm with a problem that i have to get the json from here:http://templodasdeusas.com.br/game/srv/ game.php?SRV =家庭 有一个选项也添加回调函数的名称,如:the...

我是一个问题,我必须得到JSON从这里开始:

i'm with a problem that i have to get the json from here:

http://templodasdeusas.com.br/game/srv/ game.php?SRV =家庭

有一个选项也添加回调函数的名称,如:

there is an option too to add callback function name like:

的http://templodasdeusas.com.br/game/srv/game.php?srv=home&callback=myFunction

这将返回类似: myFunction的({'msgd':'值'});

我想打呃使用jQuery Ajax请求,这可能吗?我仍然接受错误与正常$就要求,我被告知,我必须使用JSONP或跨站点脚本...它是如何工作的?有人得到了一个为例? TNX!

i want to make um ajax request using jQuery, is that possible? i still receiving error with the normal $.ajax request, i was told that i must use jsonp or cross site scripting... how it works? someone got an exemple? tnx!!

推荐答案

jQuery也该透明的你,如果你把回调=?在URL中。请参见为 $ API入口。的getJSON 。你基本上可以忘掉请求的跨域性。

jQuery does this transparently for you, if you put callback=? in the URL. See the API entry for $.getJSON. You can basically forget about the cross-domain nature of the request.

所以,你可能做这样的事情:

So you might do something like this:

$.getJSON(
    'http://templodasdeusas.com.br/game/srv/game.php?srv=home&callback=?',
     function(data) {
         // use the response, contained in the data object, e.g.
         alert(data.msgd);
     }
);
阅读全文

相关推荐

最新文章