| | |
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
Views: 1162 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email emptydisplayvalue error explodefunction file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery keywords limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search searchbox select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





