ASP.NET calling Webmethod using jQuery

To call Webmethod asynchronously in through jQuery

Javascript Code

<script type=”text/javascript”>
function Authenticate() {
		type: "POST",
		url: "/login.aspx/Authenticate",
		data: "{ provide json data }",
		contentType: "application/json; charset=utf-8",
		dataType: "json",
		success: function(msg) {
			if (msg.d == '1') {
			} else {
				alert("not authenticated");
		error: function() {
			alert("Error :(");

Code in ASPX.cs file

public static int Authenticate(string UserID, string Password)
	// authenticate and return value

ASPX code

<a href=”javascript:Authenticate();” data-role=”button” data-theme=”b” data-inline=”true” runat=”server”>Login</a>

Leave a Reply

Your email address will not be published.