39
 function CallMethod() {
     $.getJSON('/website/RESTfulService.svc/LiveLocation/json?{x=1,y=2}', function(data) {
         getResult(data.lat, data.lon);
     });
 }
Zheileman
  • 2,509
  • 20
  • 23
Abdallah
  • 391
  • 1
  • 3
  • 3

3 Answers3

92

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);
     });
}
Zheileman
  • 2,509
  • 20
  • 23
11

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
});
Holger Ludvigsen
  • 2,320
  • 1
  • 26
  • 31
4

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

Tal Tikotzki
  • 373
  • 3
  • 7