JSFiddle - React, Tailwind, and code Playground
JavaScript
$.ajax({
type: "POST",
url : "http://api.yutagz.com/users",
data: "test=test",
success : function(data){
alert("OK : "+data);
console.log(data);
},
error:function (xhr, errorType, thrownError){
console.log(xhr);
//=>no responseText but i'm sure the api send it
//=>xhr.status = 0 ... :|
switch (xhr.status) {
case 404: alert("404");
case 400: alert( xhr.responseText );
// Take action, referencing xhr.responseText as needed.
}
}
});