Question: I'm trying to a jquery ajax call on jsfiddle but am having an issue:

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

var res = ajax1();
console.log(res);

```

prints an entire deferred object to the console. It includes `responseText` which I thought perhaps is what I should try to access, but I get undefined.

```
console.log(res.responseText);

```

[I tried this once before](https://stackoverflow.com/questions/16820632/jsfiddle-return-html-with-jquery-when) with HTML and everything seemed to work, but the JSON is failing for some reason.

Answer: 
ajax returns a promise object, not the result of the ajax request. You need to register a success callback to get the value returned by the ajax request

It should be

```
var ajax1 = function () {
    return $.ajax({
        type: "post",
        url: "/echo/json/",
        //also the format for json request is as follows
        data: {
            json: JSON.stringify({
                name: "thomas!"
            })
        },
        dataType: 'json'
    });
};

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

```

Demo: [Fiddle](http://jsfiddle.net/arunpjohny/A4uJu/)
You are correct, JQuery returns a Deferred object instance.

You should therefore be calling done() on the object to get the data:

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

```

[$.ajax()](http://api.jquery.com/jQuery.ajax/) returns a [jqHXR](http://api.jquery.com/jQuery.ajax/#jqXHR) instance (which implements the Deferred pattern). When you return this from the function you are returning the jqHXR object. This implements a done() method which is passed a callback function.