I tried calling the method from Ajax code, and my ajax code just doesn't get into Method. what could be the problem in my code?
C # Method:
[WebMethod]
public static bool UserNameExists(string sendData)
{
bool a;
a = DataCheck.CheckDBUser(sendData);
return a;
}
Ajax:
$('#Button2').click(function () {
var name = document.getElementById('<%= UserTxt.ClientID %>').value;
$.ajax({
type: 'POST',
url: 'Register.aspx/UserNameExists',
data: '{ }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(msg) {
if (msg.d == true) {
$("#UserLb").text("User Name is OK!");
} else {
$("#UserLb").text("User Name NOT avliable!");
}
}
});
});
Please note: when I used alert (); the team just check to see if it works - that was fine.
Thank.
source
share