Reputation: 1
I'm trying load json file (from localhost) named questions.json
by function:
function loadJson() {
$.ajax({
dataType: "json",
url: "questions.json",
succes: function() {
console.log("ajax succes");
},
error: function(object, error, errorThrow) {
console.log("ajax fail");
console.log(object);
console.log(error);
console.log(errorThrow);
}
});
}
and i run function in my script $(document).ready(loadJson());
In developer tools in Google Chrome looks everything OK (Status Code 200, preview shows valid json...), but console.log in both functions (succes and error) dont't write nothing. There aren't any other error messages.
If I change dataType to nonsense
, function in error is fired.
What could be wrong?
Upvotes: 0
Views: 48
Reputation: 74738
What could be wrong?
seems to be a typo with your success
callback:
succes // <---missing a 's' in success
change to this:
success:function(){}
Upvotes: 1