Tuesday, 15 January 2013

call pagemethod using ajax

$(document).ready(function() {
     $("#btn_submit").click(function () {
      debugger;
      $.ajax({
       type : "POST",
       url : "Ajax.aspx/show",
       data : "{'str':'rahul'}",
       contentType : "application/json;charset=utf-8",
       dataType : "json",
       success : aa,
       error : bb
      });
     });
    });

    function aa(response)
    {
      alert("success");
      debugger;
    alert(response.d);
    }   
    function bb(response)
    {
    alert("error");
    }


[WebMethod]
    public static string show(string str)
    {
        return str;       
    }

No comments:

Post a Comment