Ajax help please...

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Sep 2009
Posts: 2
Reputation: ajithredsmoke is an unknown quantity at this point 
Solved Threads: 0
ajithredsmoke ajithredsmoke is offline Offline
Newbie Poster

Ajax help please...

 
0
  #1
Sep 9th, 2009
I'm a newbie in programming.
I spent few hours yesterday and today working on a small AJAX page with multiple combo boxes that are populated from the database. I use IE6 99% of the time and I utilize the excellent . I almost done with the page (I’m pretty proud of it too) so I decided to show it to my work buddy. On both IE8 and opera, my beautiful double combo boxes just failed miserably. A part of what I was doing was to populate a double combo box with dynamic data from the database. I created an empty SELECT tag (dynamically via JS), assigned its an ID, made an AJAX request, then populated the empty SELECT tag via the innerHTML with the AJAX response, which is a list of OPTION elements. On IE6, the double combo works so well that I thought it was time wrap up the project. However, on other browsers, the combo box just mysteriously failed to get populated.

First of all, I tried to eliminiate the possibility of my AJAX requests got messed up somewhere. I traced through the flow of the functions and put alert() to assert the responses of the AJAX requests.Everything works fine except the second combo.

Here's the ajax code..


  1. function selected()
  2. {
  3. //alert("entered in function");
  4.  
  5. var xmlHttp;
  6. var str = document.form1.coursename.value;
  7. var bname = navigator.appName;
  8. var vname = bname + navigator.appVersion;
  9.  
  10. alert(str);
  11.  
  12. try
  13. {
  14. //alert(vname);
  15. //explorer 7+,firefox,safari,chrome,opera and others
  16. xmlHttp = new XMLHttpRequest();
  17.  
  18.  
  19. }
  20. catch(e)//for IE
  21. {
  22. try
  23. {
  24. //alert("ie6");
  25. //for explorer 6.0
  26. xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  27. }
  28. catch(e)
  29. {
  30. try
  31. {
  32. //alert("ie>6");
  33. //explorer > 6
  34. xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  35.  
  36. }
  37. catch(e)
  38. {
  39. //explorer < 4
  40. alert("Ajax is not supported by your browser");
  41. }
  42. }
  43. }
  44.  
  45. xmlHttp.onreadystatechange = function()
  46. {alert("entered in state changed");
  47. if(xmlHttp.readystate == 4)
  48. {
  49. document.getElementById("subjectplace").innerHTML = xmlHttp.responseText;//subjectplace is the id of div tag
  50. alert("readystate=4");
  51. }
  52. }
  53. xmlHttp.open("get","mypage.php?q="+str,true);
  54. xmlHttp.send(null);
  55.  
  56. }


Any Kind of help will be appreciated..
Thanks in advance..
Last edited by Ezzaral; Sep 9th, 2009 at 1:34 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reply With Quote Quick reply to this message  
Reply


This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



Tag cloud for ajax, ajaxcode, ajaxexample, ajaxhelp, codes, javascript, php, programming, software
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC