Internet Explorer inserting select options from ajax call

This seams to work in firefox and chrome, but not internet explorer. I need this to work in internet explorer.

IE is appending the opening tag and not the inner text and closing tag. Thanks in advance.

JS:

function go() {
   $.post("ajax-select.html", "", function(resp){
      $('#dropdown').append($('#newOptions option', resp));
   }
}

HTML:

<body>
   <select id="dropdown">
   </select>
   <input type="submit" value="go" onclick="go();" />
</body>

ajax-select.html:

<div>
   <div id="newOptions">
      <option value="opOne">one</option>
      <option value="opTwo">two</option>
   </div>
</div>

Answers


You should try

$('#dropdown').html($('#newOptions option', resp));

Also have a look at this answer


Your response is not correct. The actual HTML coming back is:

<div>
  <div id="newOptions">
    <div value="opOne">one</div>
    <div value="opTwo">two</div>
  </div>
</div>

Correct it, and all works properly:

<div>
  <select id="newOptions">
    <option value="opOne">one</option>
    <option value="opTwo">two</option>
  </select>
</div>

With the above markup (options properly nested within a select element), you can continue using the following:

$(function(){
    $("input[value='go']").on("click", function(){
        $.post("ajax-select.html", function(resp){
            $(resp).find("option").appendTo("#dropdown");
        });
    });
});

Need Your Help

how do i get an always changing value from a string c#

c# string world-of-warcraft

I am working on a program that will automatically get your characters stats and whatnot from the wow armory. I already have the html, and i can identify where the string is, but i need to get the "...

Alloc more than one object at the time

ios objective-c memory-management nsobject nsset

I would like to know how to allow more than one object at the time. I am looking for something like NSSet with 50 empty Objects.