문제

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?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top