display result in status after it post
- by nisardotnet
my question is continuation of what i have posted here
i want to know how to display a result status based on my return result from Web Method
here is my post code:
beforeSubmit: function(data) {
var myData = { "firstName": escape($('#txtFirstName').val()), "lastName": escape($('#txtLastName').val()) };
$.ajax(<br>
{
type: "POST",
url: "VisitorWS.asmx/AddVisitors",
data: JSON.stringify(myData),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data)
{
$("#status").fadeTo(500, 1, function() { $(this).html("You are now registered!").fadeTo(5000, 0); })
},
error: function(data) {
$("#status").fadeTo(5000, 1, function() { $(this).html("Failed!").fadeTo(5000, 0); })
}
});
WebMethod
[WebMethod]
public bool AddVisitors(string firstName, string lastName)
{
if (firstName == "test")
{
return true;
}
return false;
}
so based on true or false i want to display a message on the client side.