$.ajax({
url: 'http://jsonplaceholder.typicode.com/posts/1',
method: 'GET',
}).done(function(data){
console.log(data);
console.log(data.responseText);
});
Can anyone help me understand why console.log(data.responseText);
is returning undefined?
http://clarkben.com/ajaxtesting/
Edit: OK so it looks like data is not a jqXHR object. If a assign the whole $.ajax statement to a variable then that variable is a jqXHR object so it can be accessed that way. I'm not sure why the data passed in to the function that is part of .done is not a jqXHR object though.
var theRequest = $.ajax({
url: 'http://jsonplaceholder.typicode.com/posts/1',
method: 'GET',
}).done(function(data){
console.log(data);
console.log(theRequest.responseText);
});
console.log(data); returns an object
It was edited out of your question at some point. I question whether not it's actually an object, or if it's json and you're just mis-interpreting it as being an object. – Derryberry