I'm using a jquery ajax for storing a data in the database. I call a service through a url and send data to it in the following way:
$.ajax({
type: "POST",
url: "http://192.168.250.118:8080/rest_service/rest/user",
data: JSON.stringify({ "loginName": "[email protected]", "mobile": "1234567890" }),
async: false,
contentType: "application/json",
crossDomain: true,
success: function(data){
alert("success");
},
error: function(XMLHttpRequest, textStatus, errorThrown){
console.log(XMLHttpRequest);
console.log(textStatus);
console.log(errorThrown);
}
});
When I execute this, I get this error:
{"readyState":0,"status":0,"statusText":"error"}
This is what I get when I look for errors in network:
But, if I try using postman, the data is getting stored and I get 200OK
response. What's wrong with the above code? What should I change?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…