jQuery html attribute not working in IE

前端 未结 24 2547
[愿得一人]
[愿得一人] 2020-12-01 14:32

I am using country and state dropdowns in my form. Whenever the user selects the country in the dropdown, the respective states of the country will populate in the states dr

相关标签:
24条回答
  • 2020-12-01 15:07

    This is what worked for me: (I tested on IE7 - IE9, and Chrome)

    It looks like the trick for IE is to use a DIV wrapper

    Original html:

    <div  id="dynamicMenu"></div>
    

    jQuery script:

    $.ajax({
    
                url: "/myapp/myajaxUrl.jsp",
                type: "GET",
                dataType: "html",
                async: false,
                success: function(msg) {
                    $("#dynamicMenu").html(msg);
                });
    

    Where msg is something like:

    <TABLE>
    <TBODY>
     <TR>
      <TD><LABEL for="dropdown1">OS type:</LABEL></TD>
      <TD>
       <SELECT id="dropdown1">
        <OPTION selected value="">Select OS</OPTION>
        <OPTION value="WIN">Windoze</OPTION>
        <OPTION value="UX">Unix</OPTION>
        <OPTION value="LX">Linux</OPTION>
       </SELECT>
      </TD>
     </TR>
    </TBODY>
    </TABLE>
    

    I tried .empty() .html() to no avail but the above worked great!

    0 讨论(0)
  • 2020-12-01 15:08

    Jukums' comment led me to try turning off ColdFusion debug output and then .html() worked for me in IE8. To force debug output off:

    <cfsetting showdebugoutput="No">
    
    0 讨论(0)
  • 2020-12-01 15:08

    On my case too the returned data should be syntactically correct. I had some unmatched tags like , unclosed tags

    or .. etc

    check if all data is correct

    if this is an ajax request, then quick way for debug would be to add a text area outside the area you populate and populate the text area with the returned data. then check that data for inconsistencies. Jquery.html is working fine with IE

    0 讨论(0)
  • 2020-12-01 15:09

    Also (in my case) check if you have valid html, I had mismatched tags, and it worked in firefox and didn't in IE(6-8)

    0 讨论(0)
  • 2020-12-01 15:10

    In IE8 go to tools-> internet options-> then select the advanced tab. Then click reset to reset all internet explorer settings.

    I thought I had a problem with my code but the problem was IE8. This worked a treat.

    Good luck and hope this helps.

    0 讨论(0)
  • 2020-12-01 15:10

    In my case the problem was with the way I was commenting out my javascript in the data being loaded.

    // Works fine
    
    /* Works fine */
    
    <!-- This causes a syntax error in IE -->
    

    I've never had any problems commenting out like that in IE before, only when using ajax to load it into an existing page. No problem with th eother browsers either.

    0 讨论(0)
提交回复
热议问题