如何将参数传递给JQuery $ .getJSON回调方法?

如何将参数传递给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);
     });
}