如何将参数传递给JQuery $ .getJSON回调方法? [英] How to pass parameters to a JQuery $.getJSON callback method?
本文介绍了如何将参数传递给JQuery $ .getJSON回调方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function CallMethod() {
$.getJSON('/website/RESTfulService.svc/LiveLocation/json?{x=1,y=2}', function(data) {
getResult(data.lat, data.lon);
});
}
推荐答案
将它们作为对象传递在URL之后和函数之前:
Pass them as an object just after the URL and before the function:
function CallMethod() {
$.getJSON('/website/RESTfulService.svc/LiveLocation/json',
{
x: "1",
y: "2"
},
function(data) {
getResult(data.lat, data.lon);
});
}
这篇关于如何将参数传递给JQuery $ .getJSON回调方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文