Grigor
Grigor

Reputation: 4059

extjs alert response

I have the following code

Ext.Ajax.request({
    url: 'newRecord.php',
    method: 'POST',
    type: 'json',
    params: {
        "author" : list.Author,
        "title" : list.Title,
        "manufacturer" : list.Manufacturer,
        "product_group" : list.ProductGroup
    },
    success: function(response) {
        alert(response.author);
    },
    failure: function() {
        alert('Failure');
    }
});

the alert returns undefined however my php returns {"author":"The author here"}

what is the mistake here?

Upvotes: 1

Views: 120

Answers (1)

Grigor
Grigor

Reputation: 4059

I found an answer after some research:

The trick is to put this in success function

// resp is the XmlHttpRequest object
var options = Ext.decode(resp.responseText).author;
alert(options);

Upvotes: 3

Related Questions