I am sending data from a form via Jquery AJAX with JSON formatted data. The file processing on the server is a ASHX Handler.
Below - code snippet:
// Jquery AJAX JSON ...
$.ajax({
type: "POST",
url: "handler.ashx",
data: $.toJSON(formdata),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(response) {
$('#ajax-loader').hide();
$('#msg').html("Ok!");
},
error: function(response) {
$('#ajax-loader').hide();
$('#msg').html("Error!");
}
});
// handler.ashx...
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string json = RequestBody(context.Request);
JavaScriptSerializer js = new JavaScriptSerializer();
FormData formdata = js.Deserialize<FormData>(json);
// Business Process ...
// ...
context.Response.Write("OK - All Right");
}
However, Jquery always performs the error instead of success callback function, even if the server everything worked. What can be happening?
Success callback not triggering. Which adjustments do you recommend?
Obs: always Status Ok 200 - Firebug Response.