jQuery html attribute not working in IE

前端 未结 24 2548
[愿得一人]
[愿得一人] 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 14:53

    If you are parsing xml using jquery, and you need html() in IE, try this:

    var content = ($.browser.msie) ? $(this).context.xml : $(this).html();

    This solved my problem. I hope it will help someone too.

    Greetings.

    0 讨论(0)
  • 2020-12-01 14:55

    Check that any JavaScript in the returned data is syntactically correct.

    I had a JSON options object that had a trailing comma, and that was enough for IE to refuse to run it.

    0 讨论(0)
  • 2020-12-01 14:56

    After hours of frustration I realized that IE does not support jquery attribute functions for html5 elements other than div. I was trying to do this:

    success: function (response, textStatus, XMLHttpRequest) {
        $response = $(response.replace(/\t/g, " "));
        $responseHTML = $response.find("#pageContainer").html();
        $container.html($responseHTML);
    

    For this element:

    <nav id="pageContainer" class="content">
    </nav>
    

    By changing it to this it solved the problem:

    <nav>
        <div id="pageContainer" class="content">
        </div>
    </nav>
    
    0 讨论(0)
  • 2020-12-01 14:57

    I had the same problem after receiving an AJAX HTML-Request with the function jQuery.ajax() and then trying to parse the result with jQuery( html_result_data ). The solution was to strip the header and all tabs and "returns" in the html_result_data like this:

    success: function( data ) {
       // God this is ugly
       data = data.split("<body>")[1].split("</body>")[0];
       data = data.split("\t").join("").split("\r").join("").split("\n").join("");                      
       data = jQuery( data );
       ...
    }
    
    0 讨论(0)
  • 2020-12-01 14:59

    In my case it was so easy like change the jquery version. I was using jquery-1.3.2 and I was add this line

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script>
    

    instead jquery-1.3.2 import. Without changing anything in my source code, the .prepend function works perfectly in IE, FF and Chrome.

    0 讨论(0)
  • 2020-12-01 14:59

    Also note that if you use a tagName prefix in your selector it is slower than just using the id.

    In your case just use $("#edit-state").append(options)

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