PDA

View Full Version : Ajax to pull php require() files



DssTrainer
08-10-2006, 01:09 PM
I'm trying to use AJAX based tabs like the ones found at DD and I would like to pull the data from a php require(blah.php) as the content inside the tab container. Currently I use DHTML to show/Hide the <div>'s but ajax would be a better use of bandwidth to keep the initial information down in size unless the extra information was needed. I am unsure tho how to do that, or if it is even possible to load a require after the rest of the page has already loaded.

Has anyone tried anything like this or have any ideas?

blm126
08-10-2006, 02:13 PM
If the code in the required file depends on code in the original file, then it can't be done. If you still want to try. Google can help (http://www.google.com/search?hl=en&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=Beginner+Ajax+tutorial&spell=1)

DssTrainer
08-10-2006, 02:16 PM
If the code in the required file depends on code in the original file, then it can't be done. If you still want to try. Google can help (http://www.google.com/search?hl=en&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=Beginner+Ajax+tutorial&spell=1)

ya i checked google for this (although this would hardly be beginner ajax stuff) and no one seems to have done it either so I figured the latter would be the problem.

blm126
08-10-2006, 02:25 PM
No, you don't understand. PHP is serverside. AJAX is (mostly) client side. If your PHP file you would like to display depends on code on the original page, then it can't be done (easily). If it doesn't then this is standard(inaccessible) AJAX.

Twey
08-10-2006, 05:35 PM
Depends how often the content in the tabs will change, and how big it is. If it's not likely to change more than, say, once an hour, and it totals less than, say, 512K (not including images), there's no need to use AJAX at all. Load it directly into a <div> using PHP, then hide that <div> using Javascript, to be shown when the appropriate tab is pressed. This solves both your problems.

DssTrainer
02-20-2007, 12:35 PM
No, you don't understand. PHP is serverside. AJAX is (mostly) client side. If your PHP file you would like to display depends on code on the original page, then it can't be done (easily). If it doesn't then this is standard(inaccessible) AJAX.

No, I do understand that. But I don't know Serverside Ajax that well, and yes the php file does depend on the original page so you did answer what I already assumed.



Depends how often the content in the tabs will change, and how big it is. If it's not likely to change more than, say, once an hour, and it totals less than, say, 512K (not including images), there's no need to use AJAX at all. Load it directly into a <div> using PHP, then hide that <div> using Javascript, to be shown when the appropriate tab is pressed. This solves both your problems.

Well that's what I already had... I was just seeing if Ajax would work for me as an alternative... but it looks like it won't so I'll just leave it as is.

Thx