如何使Ajax和JQuery的跨站点脚本? [英] How to make an ajax with JQuery with cross site scripting?
问题描述
我是一个问题,我必须得到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);
}
);
这篇关于如何使Ajax和JQuery的跨站点脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!