views:

37

answers:

2

The following is the json response

{"d":[{"__type":"Treking.Data.Users.Owner","MembershipId":null,"FirstName":"siva","MobileNo":"9886811237","EmailId":"[email protected]","PhoneNo":""}]}

Client Side js is as follows

function GetInfo() {

        var checkboxInfo = $('#&lt%= chkboxContact.ClientID %&gt');
       var domcheckboxInfo=  checkboxInfo[0];
       if (domcheckboxInfo.checked == true) {

           $.ajax(
        {
            type: "Post",
            url: "../ProfileService.asmx/GetUserInfo",

            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                var str = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                for (var i = 0; i &lt str.length; i++) {
                    var firstname = str[i].FirstName;
                    var MobileNo = str[i].MobileNo;
                    var EmailId = str[i].EmailId;
                    var PhoneNo = str[i].PhoneNo;
                }
                $('#&lt%=txtboxContactperson.ClientID %&gt').text = firstname;
                $('#&lt%=txtboxEmailId.ClientID %&gt').text = EmailId;
                $('#&lt%=txtboxMobileNo.ClientID %&gt').text = MobileNo;
                $('#&lt%=txtboxTelephone.ClientID %&gt').text = PhoneNo;

            }, failure: function (response) {
                alert(response.d + "FAILED");
            }
        });



       }
    }

i have a asp.net checkbox with an id of chkboxContact onchange i call this javascript function. but the control jumps of the success and it does not enter it ,the control from sucess jumps to failure but does not enter the failure function.Please Guide

+1  A: 

Like Nick Craver said, there is no failure function, only error. Note that if the call errors, it will never enter the success function, only the error result will be returned.

error: function(XMLHttpRequest, textStatus, errorThrown) { 
   alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
Zacho
A: 

Thanks for the quick response but i am still the problem is not solved after i used error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown); }

it still does not enter success or failure

naveen
please don't post this as an answer. Edit your original question or add a comment with your continuing issues.
Alastair Pitts