Why is the getJSON function structured this way?
$.getJSON( url [, data ] [, success ] )
Instead of just returning an object, i.e.:
var myjson = $.getJSON( url [, data ])
Why is the getJSON function structured this way?
$.getJSON( url [, data ] [, success ] )
Instead of just returning an object, i.e.:
var myjson = $.getJSON( url [, data ])
Because it returns a jqXHR object that contains responseText and responseXML properties, as well as a getResponseHeader() method. When the transport mechanism is something other than XMLHttpRequest (for example, a script tag for a JSONP request) the jqXHR object simulates native XHR functionality where possible. Basically, how would you know if the request was successful?