jQuery ajax not working in IE???

Discussion in 'jQuery' started by M.Zeb Khan, Oct 17, 2008.

  1. #1
    Hi,

    It's a jQuery script which updates <select> drop down on the spot....

    It's working perfect in GoogleChrome and FF, but this damn IE, its not working.


    Here is the jQuery code....
    
    $(function(){
      $("select#State").change(function(){
        $.getJSON("cities.php",{id: $(this).val(), dataType: "json", ajax: 'true'}, function(j){
          var options = '';
          for (var i = 0; i < j.length; i++) {
            options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
          }
          $("select#City").html(options);
        })
      })
    })
    
    Code (markup):
    Here is the PHP code of cities.php
    
    $result = $db->query("SELECT * FROM us_cities WHERE ST = '$_GET[id]' ");
    
    	echo "[ ";
    while($grab = $db->fetch_array($result)) {
    	echo "{optionValue: '$grab[City]', optionDisplay: '$grab[City]'},"; 
    }
    	echo " ]";
    
    
    PHP:
    It works perfectly!! in FF, I hate Internet Explorer
     
    M.Zeb Khan, Oct 17, 2008 IP