Showing posts with label Error. Show all posts
Showing posts with label Error. Show all posts

Thursday, September 1, 2011

jQuery $.ajax–Error:Internal Server Error

The javascript code:

    var dataString = "{Id:'" + id+ "',name:'" + name+ "'}";
   
    $j.ajax({
        type: "POST",
        url: "Default.aspx/SubmitName",
        data: dataString ,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (message) {
            alert('Thank you!');
        },
        error: function (jqXhr, textStatus, errorThrown) {
            alert("" + textStatus + "; " + errorThrown);
        }
    });

The server side function:

    [System.Web.Services.WebMethod()]
    public static bool SubmitName(string id, string name)
    {
       //some logic here
        return false;
    }

This code would receive an “Internal Server Error” 500 because in the JS the first parameter name is “Id” while on the server side it is “id”. The parameter names have to be the same (including casing!).

Tuesday, August 12, 2008

ASP.NET Custom Error pages

A great explanation about where and how errors can be caught in ASP.NET application and how to build custom error pages.

Link