-1
iOS에서 jQuery Mobile을 사용하여 인증 API를 구현하려고합니다. jQuery.ajax()
을 사용하여 게시물 요청을 보내고 있지만 코드가 작동하지 않습니다.jQuery 게시 요청 실패
코드는 아래에 나와 있으며 iOS 용 Phonegap과 함께 jQuery Mobile 프레임 워크를 사용하고 있습니다.
이 코드에 문제가 있습니까?
HTTP 오류 코드가 반환 될 수 있습니까 (예 : 500, 404 등)?
index.html
[object Object]
편집을 : 몇 가지 의견을 읽고 나면, 내가 지금 사용하고
<input id="clickMe" type="button" value="Authenticate Me" onclick="authenticate();" />
내가 말하는 경고보기를 얻을 - 나는 HTML을 통해 코드를 테스트 할 때
function authenticate() {
$.ajax({
url: "https://someurl.com/authenticateUser",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify("{\"jsonText\": \"{ \"username\" : \"Test\", \"password\" : \"testing123\" } \"} "),
success: function (result) {
alert(result);
},
error: function (result) {
console.log(result);
}
});
}
console.log (result)
이 로그에 표시되는 오류 메시지입니다.
{"readyState":4,"responseText":"{\"Message\":\"Cannot convert object of type \\u0027System.String\\u0027 to type \\u0027System.Collections.Generic.IDictionary`2[System.String,System.Object]\\u0027\",\"StackTrace\":\"
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)\\r\\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)\\r\\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer)\\r\\n at
System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\\r\\n
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\\r\\n
at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\\r\\n
at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\\r\\n
at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)\",\"ExceptionType\":\"System.InvalidOperationException\"}","status":500,"statusText":"Internal Server Error"}
디버깅에'alert'를 사용하지 말고,'console.log'를 사용하십시오. – undefined
인스펙터를 사용하여 네트워크 트래픽을 보면, 무슨 일이 일어나고 있는지 알 수 있습니다. – cgatian
제안에 감사드립니다. 이제 위에서 게시 한보다 자세한 오류 메시지가 표시됩니다. –