I am calling my static web method from html page using ajax. but it doesn't hit my method rather it reload the page. My script is below
$(document).ready(function() {
$("#btnSave").click(function () {
alert("Clicked");
var name = $("#txtFirstName").val();
alert(name);
// do the extra stuff here
$.ajax({
type: "POST",
url: "AddEditStudent/SaveData",
data: '{name: "' + name + '" }',
success: function() {
//$('.simple-sucess').fadeIn(100).show();
//$('.contact_form').fadeOut(100).hide();
// $('.simple_error').fadeOut(100).hide();
},
failure: function () {
alert("fail");
}
and my code behind method is
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
}
}
[WebMethod]
public static string SaveData(string name)
{
return "hello";
}