/*
* Hello Brandley, tonight I've tried to figure out how to do proper
* JSON POSTs using "Content-type: application/json" and serialized JSON
* data in the content portion (body) of my HTTP requests. This is
* specified in the Twitter API for status updates and Identica JSON
* webservices (found via Mark Pilgrim).
* After some tests, I had to recognize that jQuery does not support JSON
* encoding in the core distribution and aside of $.getJSON(), there
* is no $.postJSON().
* Below is an proposed update. As it relies on your json plugin, I'd ask
* you to add it to your code base so that other jQuery users can benefit
* of it.
*/
$.postJSON = function(url, data, callback) {
return jQuery.ajax({
'type': 'POST',
'url': url,
'contentType': 'application/json',
'data': $.toJSON(data),
'dataType': 'json',
'success': callback
});
};
→ visit project
This entry was posted
on Sunday, October 18th, 2009 at 12:50 am and is filed under Uncategorized.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.