ASP.NET Read single value from web service using jQuery

Web service:

[WebMethod]public string IsDOBValid (string date){    DateTime value;    IFormatProvider culture = new System.Globalization.CultureInfo("en-CA", true);    if (DateTime.TryParseExact(date, "M/d/yyyy", culture, System.Globalization.DateTimeStyles.None, out value))    {        return "true";    }    return "false";}

HTML

<input id="Button1" type="button" value="Get Next User" onclick="javascript:IsDOBValid('4/4/1999'); return false;" />

jQuery

function IsDOBValid(date){    var ws = "/Webservices/Content.asmx/IsDOBValid?date=" + date;    $.ajax({    type: "GET",    url: ws,    cache: false,    dataType: "xml",    success: function (xml) {           alert($(xml).find('string').text());    }})

Leave a Reply

Your email address will not be published. Required fields are marked *