In the code below, I'm handling for status code 200 and 401. What do I do if I want to direct control to a function that handles all codes apart from 200 and 401?
$.ajax({
type: "POST",
dataType: "json",
data:POSTData,
url: 'http://localhost/api/user/authenticate',
statusCode: {
200: function() {
alert("ok");
},
401: function() {
alert("Invalid Credentials");
}
}
});
try something like this:
$.ajax({
type: "POST",
dataType: "json",
data:POSTData,
url: 'http://localhost/api/user/authenticate',
complete: function(xhr, statusText){
switch(xhr.status){
case 200:
alert("ok");
case 401:
alert("invalid credentials");
....
etc
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With