postJSON

by Neal

JavaScript

(function($) {
    $.postJSON = function(url, data, ret_fn) {
        return $.post(url, data, ret_fn, 'json');
    };
})(jQuery);


var myJSONObject = {
    text: 'some text',
    array: [1, 2, 'three'],
    object: {
        par1: 'another text',
        par2: [3, 2, 'one'],
        par3: {}
    }
};

$.postJSON('/echo/json/', {
    json: JSON.stringify(myJSONObject),
    delay: 2
}, function(data) {
    console.log(data);
});