i have an external JS file which is loading data from JSON using $.getJSON
(function() {
var url = "dummy.json";
$.getJSON( url,
.done(function( data ) {
console.log(data);
})
});
Whenever i load my html page related to this script, i am constantly getting this error in the console
SyntaxError: expected expression, got '.' .done(function( data ) {
My question is- What is the cause of my problem here ? Any help would be appreciated.
That's a syntax error. You should chain .done()
on a request.
(function() {
var url = "dummy.json";
$.getJSON( url, function(){
console.log('done something');
}).done(function( data ) {
console.log(data);
}).fail(function(){
console.log('something went wrong');
});
});