Solved

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

Posted on 2014-03-15
7
462 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 34

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

932 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now