Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 388723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:47:50+00:00 2026-05-12T15:47:50+00:00

I’ve been racking my head for two days trying to find a solution for

  • 0

I’ve been racking my head for two days trying to find a solution for this. I’m using jQuery.ajax() to grab values from the database to update a box when another box is changed. The php script grabs the values from the database and then spits out json. IT works fine in FF but in all versions of IE the select box doesn’t get updated. I’ve confirmed that the json being output is good.

Here is the jquery:

function getVendors(dest, selectSup) {
  var vend = $('select#sup').val();
  $.ajax({
    beforeSend: function() {
      $("select#dest").parent().addClass('loading');
    },
    type: "GET",
    dataType: "json",
    cache: false,
    url: '/search/cruiseselect/?type=vendors&supplier=' + vend + '&dest=' + dest,
    timeout: 2000,
    error: function() {
      alert("Failed to submit");
    },
    success: function(data) {
      $("select#sup option").remove();
      var any = "<option value=\"any\">-- All Cruise Lines --</option>";
      $(any).appendTo("select#sup");
      $.each(data, function(i, j) {
        if (j != null && j != undefined) {
          var sel = j.value == selectSup ? " selected" : "";
          var row = "<option value=\"" + j.value + sel + ">" + j.text + "</option>";
          //$(row).appendTo("select#sup");                  
          $("select#sup").append(row);
        }
      });
    },
    complete: function() {
      $("select#dest").parent().removeClass('loading');
    }
  });
}
jQuery(document).ready(function() {

  //dynamic select boxes 
  $("select#dest").change(function() {
    var selectSup = $("select#sup").children("option:selected").val();
    getVendors($(this).val(), selectSup);
  });
});

I’ve got this in my php

header('Cache-Control: no-cache, must-revalidate');

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

header('Content-type: application/json');


echo json_encode($json);

And it’s outputting the correct json with no extra commas or anything. What’s more is that If I use alert(j.value + j.text); in my .each() loop, I get the correct data in IE so it seems that it’s the jquery appendTo() that’s not working.

Anybody got any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:47:50+00:00Added an answer on May 12, 2026 at 3:47 pm

    I’m a bit surprised that jQuery isn’t handling this (I thought it did… maybe its the .html() that works).

    The issue is based on an IE (6,7,& 8) bug that you can’t set the .innerHTML of a select list.

    Using “vanilla” Javascript you can use the Option object to create new options and add them to a select, or you can set the entire Select list at once (e.g. including the select tags).

    var mySelect = $("select#sup").get(0);//get actual DOM element
    var newOpt,selLen;
    for(var i=0;i<10;i++){
      newOpt = new Option('Label: ' + i, i);
      //format new Option(text, value, defaultSelected, selected);
      //add new option to select object
      selLen = mySelect.options.length;
      mySelect.options[selLen] = newOpt;
    
      //This may also work, but I don't recall if IE6 supports the .push()
      //method on the options collection, if so, this line will replace the 2 above
      //    mySelect.options.push(newOpt);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 394k
  • Answers 394k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer $sql = "SELECT * FROM MY_TABLE"; $result = mysqli_query($conn, $sql);… May 15, 2026 at 2:19 am
  • Editorial Team
    Editorial Team added an answer You can do it using .map() and .html() like this:… May 15, 2026 at 2:19 am
  • Editorial Team
    Editorial Team added an answer Just do usort($trek, getSortCommand('name', 'strnatcasecmp')); usort() returns a boolean indicating… May 15, 2026 at 2:19 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.