Simple jQuery .post Ajax example

Uses the jQuery .post() method to send and receive json data.

by Aditya Sharma

HTML

<div id='status'>Status: </div>
<div id='data'>Data: </div>

JavaScript

/*
    Simple jQuery .post Ajax example.
*/
var serializedJSON = JSON.stringify({arf: "Good Doggie"});
$.post('/echo/json/', {
        json: serializedJSON,
        delay: 3
    }, null, "json")
    .done(function(data, textStatus) {
        // also called after the 3 second delay
        $('#status').append(textStatus); 
        $('#data').append(data.arf);
    });