JQuery Ajax Always Fires Error Function

Posted by CccTrash on Stack Overflow See other posts from Stack Overflow or by CccTrash
Published on 2010-05-25T08:28:26Z Indexed on 2010/05/25 22:41 UTC
Read the original article Hit count: 220

Filed under:
|

AddFileToDB.ashx:

public void ProcessRequest (HttpContext context) 
{
   context.Response.ContentType = "application/json";
   context.Response.Write("{ \"filename\": \"test.jpg\" }");
}

JQuery:

         $.ajax({
            url: 'AddFileToDB.ashx',
            dataType: 'json',
            success: function(data) {
               alert(data.filename);
            },
            error: function(data) {
               alert('error');
            },
         });

This always results in the error function being called. I don't know why? Thoughts?

AddFileToDB.ashx gets fired, but success never gets run.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX