I'm writing a small code trying to get a return of the server http status
Currently I have worked out the following code (which works), but I am wondering why the call is skipping the success and going straight to error.
This is the code I currently have:
$(document).ready(function(){
$("#test-button").on("click", function() {
$.ajax({
type: "GET",
dataType: 'jsonp',
url: "<<INSERT THE URL>>",
success: function(response) {
alert(response.status);
},
error: function(response) {
if(response.status == 200) {
// Redirecting
window.location.href = '<<INSERT THE URL>>';
} else {
alert('The organisation you entered is not available');
}
}
});
});
});
Basically I just want to know why it's skipping the success, even when getting a 200 as return.
Thanks