Solved

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

Posted on 2014-03-15
7
454 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 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

23 Experts available now in Live!

Get 1:1 Help Now