I created a post showing hoe to make RESTful calls with plain vanilla JavaScript and wanted to show how to do the same thing using JQuery. So here it is:
RESTService.prototype.doPost = function(url, data, successHandler, errorHandler)
{
$.ajax(
{
data: JSON.stringify(data),
dataType: 'json',
type: 'POST',
url: url,
beforeSend: function(request)
{
request.setRequestHeader('accept', 'application/json');
request.setRequestHeader('content-type', 'application/json;charset=UTF-8');
},
success: function(response)
{
successHandler(response);
},
error: function(response)
{
errorHandler(response);
}
});
};