jQuery: $.postJSON

Written by

Is your request very big for $.getJSON() and you are looking for post alternative in jQuery to send large amount of data? I have bad news for you: there is no such function as $.postJSON() in jQuery. But, there is a way out: we can still perform AJAX post requests in JSON format by simply adding a ‘json‘ type as a fourth parameter at the end of the usual $.post() function, like this:

$.post('action-script.php', data, function(response) {
    // handle the response
}, 'json');


1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *