You need to use Web Method for this.....
check this..
<script type="text/javascript">
function ShowCurrentTime() {
$.ajax({
type: "POST",
url: "Default.aspx/abc",
data: '{n: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function(response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
</script>
[System.Web.Services.WebMethod]
public static string abc(string n)
{
return n;
}
Calling the method abc of default.aspx or you can call any web services method...
you can also check this link...
http://asp-arka.blogspot.in/2014/01/webmethod-in-aspnet-using-jquery-and.html[
^]