...

View Full Version : What's better? Using AJAX to include external file or PHP? or other?



Homienick
08-10-2007, 02:42 AM
Hey I just wanted to know if anyone knew the best way to include an external file. using css(can you?), php, ajax or another language? What would be best, and why?

Which would be the fastest?

SteveBach
08-10-2007, 02:56 AM
Of the three items you mentioned, only one is a language. CSS (http://www.w3.org/Style/CSS/) is a format for specifying formatting information for clients (e.g. Web browsers) to interpret. AJAX (http://en.wikipedia.org/wiki/Ajax_(programming)) is a technique for loading XML data in web pages using Javascript (so the entire page does not need to be reloaded).

Can you be more specific? What do you want to include in what, for what? Most likely, PHP will do what you want. If you want to load a common HTML header on many pages, you could use:


require 'header.html';

Homienick
08-10-2007, 03:21 AM
Of the three items you mentioned, only one is a language. CSS (http://www.w3.org/Style/CSS/) is a format for specifying formatting information for clients (e.g. Web browsers) to interpret. AJAX (http://en.wikipedia.org/wiki/Ajax_(programming)) is a technique for loading XML data in web pages using Javascript (so the entire page does not need to be reloaded).

Can you be more specific? What do you want to include in what, for what? Most likely, PHP will do what you want. If you want to load a common HTML header on many pages, you could use:


require 'header.html';

ya, basically I want to have a mobile verson, and a computer version of the website.

Having one folder named 'computer' one named 'articles' and then one named 'mobile'. The reason for this is because the computer version of th website has graphics, using display:none still loads the images, just doesn't show them, I want the mobile version to be really quick. The only way to do this from what I know is to do what I just explained, have the mobile version in one folder, the articles in another, and the computer in another. Then the mobile and computer versions would both individually pull the articles for each page from the articles folder.

also, do you know a way of doing this to where I wont have to make the article file, then make an html page for the computer page, and then make another seperate page for the mobile version? because both the mobile and computer versions pull articles from the articles section.

Homienick
08-14-2007, 10:30 AM
anyone?

rafiki
08-14-2007, 10:53 AM
comp url = www.siteurl.com/page.php?dev=comp&articleid=1032
mobile url = www.siteurl.com/page.php?dev=mob&articleid=1032


$dev = $_GET['dev'];
include($dev.'.php');

Homienick
08-14-2007, 04:17 PM
sorry I'm a tad bit ignorant, the include function actually sticks the text from the php file into the page, but what does $dev = $_GET['dev']; do?

PappaJohn
08-14-2007, 04:37 PM
It gets the value of the variable "dev" from the url.

So, in rafiki's example urls, it would return either comp or mob



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum