Solved

.html() in Ajax Works in Firefox, not in IE

Posted on 2014-03-15
7
470 Views
Last Modified: 2014-03-15
I thought all was good until I tested my page in IE.  I am using ajax to build a set of dynamic dependent select boxes.   I have built up a  test case to study the problem.  The ajax is returning the correct data both in Firefox and in IE.  It seems the

$("#Suplft").html(data);

Open in new window


statement does not work in IE.   It clears the options, but doesn't load in the new values.  I have searched the web, but I haven't found the solution.   Here is a link to my test case.  Run it in Firefox and then run it in IE.

http://99.65.72.66/support_test.php

Thanks in advance

This is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

   <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
   <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
   <script type="text/javascript">

	  var reload="Yes"; 
   function init(){
	 depth.value="12";
	 $("#depth").trigger("change");  
     $("#Sup_lft").trigger("refresh")
   }  
      </script>    
      	<script type="text/javascript">
           $(document).ready(function(){   
               $("#depth").change(function(){
                     var depth=$("#depth").val();
					 var group="C140_";
                     $.ajax({
                        type:"post",
                        url:"support_get.php",
                        data:{depth: depth, group: group},
                        success:function(data){
							alert(data);
							
                              $("#Suplft").html(data);  //  THIS LINE ISN'T WORKING IN IE
							  							  
							  if (reload=="Yes") {$("#Sup_lft").val("b 6.0  314.74  364.74  140_18_12_Open");
//							  alert("reload=yes");
							  reload="No";
							  }   
                        }	
                     });
               });
           });
      </script>
</head>

<body onLoad="init()">

Depth :
        <select name="depth" id="depth">    
        <?php
        include "support_db.php";		
        $result=mysql_query("SELECT Category,Series,Glass_Support,Finish,Key_2 FROM Form_Content WHERE Category='Depth' and Series='CRY140-2'");
		 while($depth=mysql_fetch_array($result)){
        echo "<option value=$depth[Key_2]>$depth[Finish]</option>";
        } ?>
        </select>
        Support :
        <select name="Suplft" id="Suplft">
            <option>-Select Support-</option>
        </select>
        
        
</body>
</html>

Open in new window

0
Comment
Question by:jws2bay
  • 4
  • 2
7 Comments
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39931831
That works just fine in IE for me if I use <option>Hello</option> as the contents of support_get.php, so it's likely some malformed HTML content (maybe some PHP errors or warnings) coming back from the page that IE isn't understanding.
0
 

Author Comment

by:jws2bay
ID: 39931841
Here is  support_get.php

<?php
  include "support_db.php";
  $depth=$_POST["depth"];
  $group=$_POST["group"];
  $result=mysql_query("select Display_Name,Key_3 FROM Products where Pri_Group = '$group' AND Sec_Group='Lft' AND Key_1='$depth' ORDER BY Sort_Index ASC");
  while($Sup_lft=mysql_fetch_array($result)){
echo"<option value='$Sup_lft[Key_3]'>$Sup_lft[Display_Name]</option>";

  }
?>
0
 

Author Comment

by:jws2bay
ID: 39931846
I left up the alert to show what was being returned.   I don't know how the data is supposed to look like.  I can just see something is coming back.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 58

Expert Comment

by:Gary
ID: 39931857
Remove the extraneous comments from the ajax response - its not valid HTML
0
 

Author Comment

by:jws2bay
ID: 39931870
Gary

I'm not sure what you are referring to.  Can you elaborate.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39931874
Your ajax returns this for example

Connected to MySQL<br>
Connected to gdsquirrelcart

<option value='n 0.0  0.00  Select Support Style'>Select Support Style</option><option value='d  12  395.01  455.01  140_18_12_Deep'>Deep  ............ (18") NSF</option><option value='e  15  440.30  495.30  140_18_18_Extended'>Extended   .....(22") NSF</option>


It's not valid HTML - remove the bolded parts, they don't belong in a select box
0
 

Author Comment

by:jws2bay
ID: 39931898
Gary,

Just made the changes.  Looks  good.

I really appreciate the help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question