Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-03-15
7
Medium Priority
?
488 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

609 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