Webservice hitting fail function alert message everytime

I am testing a Login Page from here, jQWidgets .

In the document.ready function, I am making an ajax post call like this

<script type="text/javascript">
    $(document).ready(function () {
        $('#window').jqxWindow({ theme: "shinyblack", width: 250, height: 130, isModal: true });
        $('#submit').jqxButton({ theme: "shinyblack" });

      var loginUrl = "https://abc.com:8443/Webservice/loginCheck"

 $( "#submit" ).click(function() {

                var userName = $("#username").val();
                 var passWord = $("#password").val();

                var ajaxRequest = jQuery.ajax({
                    //beforeSend: TODO: show spinner!
                    data: {
                        username: userName,
                        passWord: passWord 
                    },
                    dataType: "json",
                    method: "POST",
                    url: loginUrl
                })
                 .done(function (data_, textStatus_, jqXHR_) {

                // Validate the web service and retrieve the status.
                if (typeof (data_) === "undefined" || data_ === null) { alert("Invalid data returned from LoginCheck Web Service"); return false; }
                if (isEmpty(data_.webservice_status) || isEmpty(data_.webservice_status.status)) { alert("Invalid Web Service Status for LoginCheck Webservice!"); return false; }
                if (data_.webservice_status.status != "SUCCESS") {   alert(data_.webservice_status.message); 


                return false; }
            })

           .fail(function (jqXHR_, textStatus_, errorThrown_) {
                    alert("Hitting the Fail function : Error in LoginCheck webservice: " + errorThrown_);
                    return false;
                });


}




    });
</script>

The Successful JSON response will be :slight_smile:

{
  "status" : "SUCCESS",
  "message" : "LoginCheck of <<your username here>>l Successful!"
}

Unsuccessfull :

{
  "status" : "ERROR",
  "message" : "LoginCheck of <<your username here>> Failed!"
}

Everytime I enter credentials and click submit, I keep getting message Hitting the Fail function : Error in LoginCheck webservice.

Why it is landing to fail function everytime, am I doing something wrong with POST Ajax call above?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.