Connecting Tech Pros Worldwide Help | Site Map

simple ajax works in chrome and FF but not IE

Newbie
 
Join Date: Nov 2008
Posts: 4
#1: Sep 20 '09
This code works in Chrome and pulls a second drop down, but it will not work in IE6, (I dont have IE7/8 to check right now, but can later) and it works in FF, in IE it doesn't do anything at all.

Thanks for any help!

php code to push data to page:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $q=$_GET["q"]; //number
  3. $blown = explode(',',$q);
  4. $q = $blown[0];
  5. $appl = $blown[1];
  6.  
  7. include "/home/advent1/public_html/secure/connect.php";
  8. $clients= "'$_SESSION[group2]'";
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. ?>
  16.  
  17. <select name="lookupanswers">
  18. <option></option>
  19. <?php
  20. $i=1;
  21. while ($i <= '10') {
  22. $p="appl_quest{$i}_yn";
  23. $m="appl_drop_{$q}_{$i}";
  24. $n="quest{$i}_yn";
  25. $sqlappl = "SELECT appl from client_table where appl = {$blown[1]}";
  26. $resultappl = mysql_query($sqlappl) or die(mysql_error());
  27. $appl = mysql_result($resultappl, 0);
  28.  
  29. $sqlapplquest = "select {$m} from lookup_table where appl = {$appl}";
  30. $resultapplquest = mysql_query($sqlapplquest) or die(mysql_error());
  31. $applquest = mysql_result($resultapplquest, 0);
  32.  
  33. if ($applquest == '') {
  34. } else { 
  35. ?>
  36. <option value="<?php echo $i; ?>"><?php echo $applquest; ?></option>
  37. <?php
  38. }
  39. $i++;
  40. }
  41. echo $sqlapplquest;
  42. ?>
Javascript code to make the ajax object.
Expand|Select|Wrap|Line Numbers
  1. var xmlhttp;
  2.  
  3. function showUser(str,appl)
  4. {
  5. xmlhttp=GetXmlHttpObject();
  6. if (xmlhttp==null)
  7.   {
  8.   alert ("Browser does not support HTTP Request");
  9.   return;
  10.   }
  11. var url="getanswer.php";
  12. url=url+"?q="+str;
  13. url=url+"&sid="+Math.random();
  14. xmlhttp.onreadystatechange=stateChanged;
  15. xmlhttp.open("GET",url,true);
  16. xmlhttp.send(null);
  17. }
  18.  
  19. function stateChanged()
  20. {
  21. if (xmlhttp.readyState==4)
  22. {
  23. document.getElementById("txtAnswers").innerHTML=xmlhttp.responseText;
  24. }
  25. }
  26.  
  27. function GetXmlHttpObject()
  28. {
  29. if (window.XMLHttpRequest)
  30.   {
  31.   // code for IE7+, Firefox, Chrome, Opera, Safari
  32.   return new XMLHttpRequest();
  33.   }
  34. if (window.ActiveXObject)
  35.   {
  36.   // code for IE6, IE5
  37.   return new ActiveXObject("Microsoft.XMLHTTP");
  38.   }
  39. return null;
  40. }
part of page its supposed to be updating.
Expand|Select|Wrap|Line Numbers
  1. Question:
  2. <select name="lookups" onchange="showUser(this.value)">
  3. <option></option>
  4. <?php
  5. $i = '1';
  6. while ($i<'10') {
  7. $sqlapplquest = "select appl_drop_{$i} from appl_table where appl = {$appl}";
  8. $resultapplquest = mysql_query($sqlapplquest) or die(mysql_error());
  9. $applquest = mysql_result($resultapplquest, 0);
  10.  
  11. if ($applquest != '') {
  12. ?>
  13. <option value="<?php echo $i; ?>,<?php echo $appl; ?>">  <?php echo $applquest; ?>  </option>
  14. <?php
  15. }
  16. $i++;
  17. }
  18. ?>
  19. </select> Answered:<d id="txtAnswers"><select></select></d>
Thanks again!
Newbie
 
Join Date: Nov 2008
Posts: 4
#2: Sep 21 '09

re: simple ajax works in chrome and FF but not IE


found the problem, <d> isn't supported in IE6...thanks guys.
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,148
#3: Sep 23 '09

re: simple ajax works in chrome and FF but not IE


What IS "<d>"?
I do not see it listed here:
http://www.w3schools.com/tags/default.asp
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#4: Sep 23 '09

re: simple ajax works in chrome and FF but not IE


it’s also not listed here http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd
Newbie
 
Join Date: Nov 2008
Posts: 4
#5: Sep 25 '09

re: simple ajax works in chrome and FF but not IE


Its sloppy at best, but i ran outta other tags that i could use there, div kept putting it on the line under.

Its cool, no worries, its really not what ANYONE should use, and i'm not defending it. but it DID work in FF and Chrome, and not in IE, and that should be pointed out. Thats all.
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,148
#6: Sep 25 '09

re: simple ajax works in chrome and FF but not IE


Did you try a <span>? Div is a block element, Span is in-line
rnd me's Avatar
Expert
 
Join Date: Jun 2007
Location: Urbana IL
Posts: 411
#7: Sep 28 '09

re: simple ajax works in chrome and FF but not IE


Quote:

Originally Posted by oneadvent View Post

found the problem, <d> isn't supported in IE6...thanks guys.

it will work, as in stuff will show up, but it doesn't respond to CSS tag selectors, or have as many dom bindings like lang and name.

this should be fixed in the next version of IE.
Reply

Tags
ajax, javascript, mysql, php