User-79977429 posted
Hi
in mu asp.net wobform project, i want to send some data to server via ajax request and webMethod, here is my simple code :
function PostData(userName) {
$.ajax({
type: 'POST',
url: 'WebForm1.aspx/IsValidUser',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: { strUserName: userName },
sucess: function (response) {
alert('success!');
},
failure: function (response) {
alert('failed!');
},
error: function (xhr, textStatus, errorThrown) {
alert('error!');
}
});
}
Here is my codeBehind :
[WebMethod]
public static bool IsValidUser(string strUserName)
{
bool bResult = false;
if (strUserName == "ali")
bResult = true;
return bResult;
}
But in runTime, always error function is occures! Does something wrong?
thanks in advance