Here is an example of how to send your parameters in json format (see the 4th line of code).
var postVar = "something to pass";
var postVar2 = "something else to pass";
var url = "http://<your_web_service>/format/json"; //example url ()web service will return data in json format)
var send = JSON.parse('{"var" : "'+ postVar +'","var2" : "'+ postVar2 +'"}'); //sending parameters to web service in json format)
response = sendRequest(url, "POST", "json","application/x-www-form-urlencoded; charset=UTF-8", false, send );
Here is the AJAX function that send/receive the data.
function sendRequest(cmd, method, data, content, sync, send){
if (send){
//post data
var webReq = jQuery.ajax({url: cmd,type: method,dataType : data,contentType : content, async : sync, data : send});
}else{
var webReq = jQuery.ajax({url: cmd,type: method,dataType : data,contentType : content, async : sync});
}
webReq.done(function( webText, status, jqXHR ) {
// Process incoming data here
response = webText;
return;
});
webReq.fail(function( jqXHR, status, errorThrown ) {
response = false;
return;
});
webReq.always(function( jqXHR, status, errorThrown ) {
return;
});
return response;
}