Ajax switch

Thread Solved

Join Date: Jul 2007
Posts: 30
Reputation: Mylena is an unknown quantity at this point 
Solved Threads: 1
Mylena Mylena is offline Offline
Light Poster

Ajax switch

 
0
  #1
Aug 19th, 2008
Hello everyone,

The ajax+php part worked well independently. When I created a switch (because I want different information from database to be displayed in different tabs), it does not go into the xmlHttp.onreadystatechange=function(). I tried all possible variations, and looked online for hours.

Can anyone help please?
Thank you


  1. var moduleidd;
  2. var xmlHttp;
  3. function loadModules(moduleid, birdid)
  4. {
  5.  
  6. switch (moduleid)
  7. {
  8. case "contentA":
  9. document.getElementById("contentA").innerHTML = "Hello";
  10.  
  11.  
  12. case "contentB":
  13. {
  14.  
  15. xmlHttp=GetXmlHttpObject();
  16. var url= "contentB.php";
  17. url=url+"?q="+birdid;
  18. url=url+"&sid="+Math.random();
  19.  
  20. xmlHttp.onreadystatechange=function(){
  21.  
  22.  
  23. if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  24. {
  25. document.getElementById("contentB").innerHTML = "test test test 123";
  26. var a = xmlHttp.responseText;
  27. document.getElementById("contentB").innerHTML = a;
  28.  
  29. }
  30. xmlHttp.open("GET",url,true);
  31. xmlHttp.send(null);
  32.  
  33. };
  34.  
  35. };
  36.  
  37. case "contentC":
  38. case "contentD":
  39. case "contentE":
  40.  
  41. }
  42.  
  43. }
  44.  
  45.  
  46.  
  47. function GetXmlHttpObject()
  48. {
  49. xmlHttp=null;
  50.  
  51.  
  52. try{
  53. //Firefox, Opera 8.0+, Safari
  54. xmlHttp=new XMLHttpRequest();
  55. }
  56. catch (e)
  57. {
  58. //Internet Explorer
  59. try
  60. {
  61. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  62. }
  63. catch (e)
  64. {
  65. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  66. }
  67. }
  68. return xmlHttp;
  69. }
Last edited by Mylena; Aug 19th, 2008 at 12:54 am. Reason: add a function
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Ajax switch

 
0
  #2
Aug 19th, 2008
Are you sure, did you put an alert() in the function to see?
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 30
Reputation: Mylena is an unknown quantity at this point 
Solved Threads: 1
Mylena Mylena is offline Offline
Light Poster

Re: Ajax switch

 
0
  #3
Aug 19th, 2008
thanks for your reply,

yes, i put alert() function and it did not display. When i put alert() just before the no-working function, the alert displays. it's strange,...
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 30
Reputation: Mylena is an unknown quantity at this point 
Solved Threads: 1
Mylena Mylena is offline Offline
Light Poster

Re: Ajax switch

 
0
  #4
Aug 19th, 2008
OOps, i solved it now, the closing brackets were wrongly aranged... how silly!
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: Ajax switch

 
0
  #5
Aug 19th, 2008
Oh, you did fix it, OK cool.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 1162 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC