Thursday, February 10, 2011

How to make AJAX Call for Database Transaction

At Page Behind make your method :

[System.Web.Services.WebMethod]
public static string SavePopUpData(string Id)
{
     //-- Your Save Data Code

}


 //-- Put following code in script tag and it will call above method using AJAX request :

In url : ""
In data:""

$.ajax({
                    type: "POST",
                    url: "Test.aspx/SavePopUpData",
                    data: "{Id':'1'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg) {
                        AlertMsg = msg.d;
                        if (AlertMsg.length > 0)
                           alert("Data Saved");
                    },
                    error: function(msg) {

                    }
                });

No comments:

Post a Comment