views:

64

answers:

2

I have a checkbox server control called chkboxContact. on check iam populating the Jason data into the textbox its working fine in Firefox but not in IE.Please Suggest .Thanks

<script type="text/javascript">
 function GetInfo() {

     var checkboxInfo = $('#ctl00_PlaceHolderCenter1_chkboxContact');
     var domcheckboxInfo = checkboxInfo[0];
    if (domcheckboxInfo.checked == true) {


    GetUserInfo();

    }
    else {
        document.getElementById("ctl00_PlaceHolderCenter1_txtboxContactperson").value = "";
        document.getElementById("ctl00_PlaceHolderCenter1_txtboxMobileNo").value = "";
        document.getElementById("ctl00_PlaceHolderCenter1_txtboxEmailId").value = "";
        document.getElementById("ctl00_PlaceHolderCenter1_txtboxTelephone").value = "";
        }
}

 function GetUserInfo() {

        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "../ProfileService.asmx/GetUserInfo",
                            async: false,
             data: "{ }", // send an empty object for calls with no parameters
            dataType: "json",
            success: displayUserInfo,
             failure: reportError
            });



  }


 function displayUserInfo(response) {

var firstname;
var MobileNo;
var EmailId;
var PhoneNo;
var str = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
for (var i = 0; i < str.length; i++) {
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxContactperson").value = str[i].FirstName;
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxMobileNo").value = str[i].MobileNo;
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxEmailId").value = str[i].EmailId;
     document.getElementById("ctl00_PlaceHolderCenter1_txtboxTelephone").value = str[i].PhoneNo;

}



 }

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



 </script> 
A: 
  • contentType is used when sending data to the server. So be sure you're really sending a JSON string utf-8 encoded.

  • data should be just an empty string or null if not used.

  • failure does not exist as valid .ajax() property. I guess you're looking for error.

http://api.jquery.com/jQuery.ajax/

jAndy
+1  A: 

Just remove charset=utf-8" from contentType: "application/json; charset=utf-8"

Should solve your problem. See: http://stackoverflow.com/questions/425854/jquery-ajax-request-failing-in-ie

gearsdigital

related questions