Reputation: 401
function CallMethod() {
$.getJSON('/website/RESTfulService.svc/LiveLocation/json?{x=1,y=2}', function(data) {
getResult(data.lat, data.lon);
});
}
Upvotes: 40
Views: 88998
Reputation: 373
Alternatively, first create javascript object for the sake of simplicity and then pass
var myObject = {x: "1", y: "2"};
$.getJSON('/website/RESTfulService.svc/LiveLocation/json', myObject, function(dataVal) {
//Use Your result
});
Upvotes: 11
Reputation: 403
Just like Zheileman said, but note that this way, although you passed the parameters in JSON format, the actual parameters are passed to the webserver as an Encoded HTTP URL which will end up this way:
/website/RESTfulService.svc/LiveLocation/json?x=1&y=2
Upvotes: 4
Reputation: 2559
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);
});
}
Upvotes: 94