Reputation: 193
Get stacked with ajax call. I'm allways getting error. I've tried to return from server ArrayList because i have some scheme in some my projects. But the result was same. Json is valid. Staus 200 OK and permanent error.
Here is my client-side code
$.ajax({
type: "POST",
url: "services.aspx/GetHexString",
data: "{'strGetParamsString':'LYALYA'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert(msg.d);
},
error: AjaxFailed
});
Server-side logic:
[WebMethod]
public static string GetHexString(string strGetParamsString)
{
return "HI";
}
Firebug shows 200 OK status. And the result is {"d":"HI"} http://jsonlint.com/ says that json is valid.
What is wrong?
Upvotes: 1
Views: 4822
Reputation: 1322
Add error_reporting(0);
to the top of your php
page. With the json
array that returns if you happen to have an Undefined variable or you have the error_reporting
on it will mess up the array data. I don't know all the full details on this but it works for me.
Upvotes: 0
Reputation: 9619
Tried your code here and it works fine. Have you added text to your error callback to display the error?
error: function (jqXHR, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
}
Upvotes: 1
Reputation: 12305
To get more information about you error, add parameters to your error callback function. From the jQuery docs:
error(jqXHR, textStatus, errorThrown)
errorThrown will contain some info.
Upvotes: 1