Skip to content

Instantly share code, notes, and snippets.

@scottmessinger
Created February 21, 2011 02:08
Show Gist options
  • Save scottmessinger/836575 to your computer and use it in GitHub Desktop.
Save scottmessinger/836575 to your computer and use it in GitHub Desktop.
I don't understand.
// This doesn't work:
> var data = $.ajax({ url : '/plans.json'}).responseText
> undefined
// However, if I set data then ask for the responseText, it does. I don't understand why this happens, but I accept it.
> var data = $.ajax({ url : '/plans.json'})
> undefined
> data.responseText
> "[{"plan":{"created_at":"2011-02-21T00:36:29Z","id":1,"updated_at":"2011-02-21T00:36:29Z"}},{"plan":{"created_at":"2011-02- etc etc......
// However, I don't understand why the following the following code doesn't work at all.
> var d = $.ajax({ url : '/plans.json'})
var data = d.responseText
console.log(d)
console.log(d.responseText)
console.log(data)
> Object
undefined
undefined
undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment