SO - 20707060

by Akram kamal

JavaScript

var ajax1 = function () {
    return $.ajax({
        type: "post",
        url: "/echo/json/",
        data: {
            json: JSON.stringify({
                name: "thomas!"
            })
        },
        dataType: 'json'
    });
};

var res = ajax1();
res.done(function (data) {
    console.log(data.name)
})