I am trying to load a remote json file asynchronously. I've just spent a long time trying to debug the function that I expected to work. I'm still relatively new to JS, and would like to understand why teh following occurs.
The function I expected to work returns undefined
.
$.ajax({
dataType: 'json',
url: $url
})
.done(function(data) {
console.log( data );
});
Whereas this function returns the expected json object
$.getJSON( $url, function( data ) {
console.log(data);
});
I thought these functions are equivalent. What is happening here?