I doubt that you even send a request. Your spaces are disabled.
Javascript does not need semicolons at the end of statements. Because of this, sometimes they appear where you do not want them.
Try putting '({' on the same line as $ .ajax. You have not seen the error because it does not exist. $ .Ajax is a valid statement, although it does nothing. Similarly, the object you create inside parentheses, is a valid object, even if it does nothing.
$.ajax({ type: "POST", ... }).done(function(r) { .... });
To answer your original question, the error takes a function as a parameter. This function takes 3 parameters in the following order:
- XHR (request)
- request status
- error that was selected (may be undefined)
An example is as follows:
$.ajax({ ... error: function(xhr, status, error) { alert("oh no!"); } })
source share