display result in status after it post
Posted
by nisardotnet
on Stack Overflow
See other posts from Stack Overflow
or by nisardotnet
Published on 2010-04-13T15:19:20Z
Indexed on
2010/04/13
15:23 UTC
Read the original article
Hit count: 166
AJAX
|webservices
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.
© Stack Overflow or respective owner