Aspx code here :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="js/jquery-1.9.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnCall").click(function () {
alert("eded");
$.ajax({
type: "POST",
url: "Default.aspx/DoSomething",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
}
});
});
});
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<button id="btnCall" type="button">Call Method</button>
</div>
</form>
</body>
</html></html>
Do what ever you want in the method
success
code behind content:
using System;
using System.Web.Services;
using System.Web.Script.Services;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
[ScriptMethod]
public static string DoSomething()
{
return "sba";
}
}