$ .ajax在Firefox中工作,但在IE中工作

时间:2010-07-20 14:14:32

标签: jquery asp.net-ajax

我有一个名为chkboxContact的复选框服务器控件。检查iam将Jason数据填充到文本框中,它在Firefox中正常工作,但在IE中没有.Please Suggest。谢谢

<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> 

1 个答案:

答案 0 :(得分:2)

只需从charset=utf-8"

中删除contentType: "application/json; charset=utf-8"即可

应该解决你的问题。请参阅:jQuery AJAX request failing in IE