Reputation:
I get the all JSON data from the server using Ajax requests. But on my side I modified the data, so I need to send the modified data to the server using JavaScript, jQuery, PhoneGap, HTML5 and Ajax.
What would be some example of doing this?
Upvotes: 0
Views: 127
Reputation: 13415
Use this:
Ext.Ajax.request({
url : serverApiUrl,
method : "POST",
scriptTag : true,
headers : {'Content-Type': 'application/json'},
scope : this,
jsonData : yourModifiedJsondata,
success : successFN,
failure : failureFN
});
function onError(jqXHR, textStatus, errorThrown) {
// Or use alerts if you can't see your log
console.log("status: " + textStatus);
console.log("errorThrown: " + errorThrown);
// can't remember if this works:
console.log(jqXHR.statusText);
}
console.log('ajaxing!');
$.ajax({
type: 'post',
url: 'PRIVATE_URL',
data: {test:'asdf'},
dataType: 'json',
success: function(data){
console.log('done');
},
error: onError
});
Upvotes: 1