jquery .html() does not work on ie8

2020-05-23 03:34发布

I have a jquery function which makes an ajax call to a webservice method on the web server, the method returns a html table with data. I am using .html() to render the return values on div. This works in Firefox,Chrome, Safari but does not work on IE8

$.ajax({
    type: "POST",
    url: "./../WebAjaxCalls.asmx/GetProductInstruction",
    data: "{'ProductID':'" + $("#txtProductID").val()  + "'}",
    success: function(data) {
        if (data.d[0] == "true") {
            **$("#dvProudctInstruction").html(data.d[1]);** 
        }
    },
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    error: function(e, textStatus, errorThrown) {
        bReturn = false;
    }
});  

The line $("#dvProudctInstruction").html(data.d[1]); works on all browsers except IE8.

Any help on this will be much appreciated.

7条回答
兄弟一词,经得起流年.
2楼-- · 2020-05-23 04:03

Just a gut feeling, but are you sure that you enter the if-block at all? I am just asking having stumbled in true vs "true" a couple of times myself...

Try:

success: function(data) {
    alert('outside of if');
    if (data.d[0] == "true") {
        alert(data.d[1]);
        $("#dvProudctInstruction").html(data.d[1]);
    }
}

Might not be anything, but at least you would eliminate the possibility that you'd simply never run the code line you've highlighted.

查看更多
登录 后发表回答