| | |
Ajax switch
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 30
Reputation:
Solved Threads: 1
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
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
PHP Syntax (Toggle Plain Text)
var moduleidd; var xmlHttp; function loadModules(moduleid, birdid) { switch (moduleid) { case "contentA": document.getElementById("contentA").innerHTML = "Hello"; case "contentB": { xmlHttp=GetXmlHttpObject(); var url= "contentB.php"; url=url+"?q="+birdid; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=function(){ if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("contentB").innerHTML = "test test test 123"; var a = xmlHttp.responseText; document.getElementById("contentB").innerHTML = a; } xmlHttp.open("GET",url,true); xmlHttp.send(null); }; }; case "contentC": case "contentD": case "contentE": } } function GetXmlHttpObject() { xmlHttp=null; try{ //Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }
Last edited by Mylena; Aug 19th, 2008 at 12:54 am. Reason: add a function
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.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
![]() |
Similar Threads
- link and the content in the same page. (JavaScript / DHTML / AJAX)
- Pass a 2D-array with AJAX (JavaScript / DHTML / AJAX)
- AJAX generated <select> and FIREFOX (JavaScript / DHTML / AJAX)
- Ajax calls wont work in FireFox! (JavaScript / DHTML / AJAX)
- Http request error when using AJAX. (JavaScript / DHTML / AJAX)
- how to read data from database page by page, please it is urgent... (JSP)
- AJAX : Am i right with the concept? (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: Chunk
- Next Thread: what is session
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





