$.ajax {readyState=0} when I set 'contentType'
-
05-06-2023 - |
Question
I'm trying to deliver a JSON object via POST to validate some information. My $.ajax request returns {readystate=4} if I do not set a 'contentType' however it returns {readystate=0} if I do set one. My code currently looks like:
var hmo ={"Data": "myDataTest"};
$.ajax({
url: "http://www.testUrl.com",
type: "Post",
data: JSON.stringify(hmo),
dataType: "json",
success: function(msg){
if(msg){
alert("Success in posting! <br /><br />" + JSON.stringify(msg));
}
},
complete: function(data){
alert(JSON.stringify(data));
},
contentType: "application/json",
});
When it runs it returns:
{"readyState":0,"responseText":"","status":0,"statusText":"error"}
Am I missing some other form of setting to ensure that the $.ajax request goes through?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow