I have attached the example file.
I have modified the AJAX function a bit to include a few more parameters:
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;
}
Here is an example of how to call the function:
var postVar = "something to pass";
var url = "http://<your_web_service>/format/json"; //example url
var send = JSON.parse('{"var" : "'+ postVar +'"}');
this.response = sendRequest(url, "POST", "json","application/x-www-form-urlencoded; charset=UTF-8", false, send );
Attachments:
You must be
logged in to view attached files.