Well, here is the story:
I have some data need to send to server, but they should turned into JSON dataType first.
I made such ajax call:
var data = {'bob':'foo','paul':'dog'};
$.ajax({
url: url,
type: 'POST',
contentType:'application/json',
data: JSON.stringify(data),
dataType:'json'
});
/** Added **/
The above does not do anything with the response from the server if you need to do something then a callback will be called when the server has responded.
var data = {'bob':'foo','paul':'dog'};
$.ajax({
url: url,
type: 'POST',
contentType:'application/json',
data: JSON.stringify(data),
dataType:'json',
success: function(data){
//On ajax success do this
alert(data);
},
error: function(xhr, ajaxOptions, thrownError) {
//On error do this
if (xhr.status == 200) {
alert(ajaxOptions);
}
else {
alert(xhr.status);
alert(thrownError);
}
}
});