Monday 18 March 2013

How to make Ajax call with post parameters


first include any jquery min file in your page and then on document.ready function or on any function of javascript you can make a ajax call like below. i am writing it on document.ready event.


$(document).ready(function () {
 $.ajax({
        type: "POST",
        url: "HandleWebRequests.aspx", //here you can use handler also ...
        data: "{email:bridzetech@gmail.com&name=bridzetech}",
        success: function (response) {
            alert(response);
        },
        error: function (response) {
            \\write code if error is returned.     
            alert(response);
        }
    });
});
 
 
and you can access these parameters on page or handler using request.form element.
like as below. i am accessing these parameters on aspx page using c#.

 string name = Convert.ToString(Request.Form["name"]);
 string email= Convert.ToString(Request.Form["email"]);
 

No comments:

Post a Comment