I got a jQuery prompt that is a password validation. I use a ajax webservice for this task. now my confusion is how should I handle the ajax call and make function bool?
I started with ajax and webservices about a 2 hours ago so be nice.
$(document).ready(function() {
$("#sayHelloButton").click(function() {
jPrompt('Password:', 'Password', 'Password', function(r) {
if (CheckPassword(r) == true) window.location = "http://www.asp.net";
else alert('Wrong password');
});
});
});
function CheckPassword(psw) {
$.ajax({
type: "POST",
url: "dummywebservice.asmx/CheckPassword",
data: "{'" + $('#name').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
}
webservice
[WebMethod]
public bool CheckPassword(string password)
{
if(!string.IsNullOrEmpty(password))
{
if (password == "testpassword")
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}