Script: DD Ajax Tabs
http://www.dynamicdrive.com/dynamici...jaxtabscontent
I want to load content from a div in another document, rather than loading the whole document. Is this possible?
Thanks,
Paul
Script: DD Ajax Tabs
http://www.dynamicdrive.com/dynamici...jaxtabscontent
I want to load content from a div in another document, rather than loading the whole document. Is this possible?
Thanks,
Paul
Not really. In a very complicated way you could get the whole page then remove all of the extra content and leave only the div. But that will be difficult to implement and inefficient.
The better solution is to set up your div to be the whole page in the first place. There are several ways to approach this, but in short you should look for a way to remove everything else from that page, either by creating a second copy of the page (with limited content) or by moving that div to a new page and including it into all pages where it is needed.
You might want to look into a serverside language like PHP to include parts of pages within others, or server side includes (SSI), or maybe a content management system. HTML (+Javascript) will only get you so far.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
I was looking to speed up a website so I've been playing around with php to include modules and I like the ease of maintenance, but the tabs were refreshing the page so I turned here to ajax.
I'll create bicycle.html for the content only, and include it in bicycle_full.php
From the menu in my main.php, I will link to bicycle_full.php as the default, i.e. for users without javascript.
With ajax, I should simply load the bicycle.html like you said.
What isn't clear to me is how to tell whether javascript is on or not, and then how to respond with either the default or the ajax?
Perhaps if the menu link pointed to bicycle_full.php and then if javascript would replace part of the name, so it grabbed bicycle.html instead?
I suspect it's something to do with manipulating strings and regular expressions, but I'm not that advanced just yet, maybe tomorrow! :P
Thanks a lot for the feedback, it is very helpful to realise I was not too far from the track!
There's almost no point at all in using Ajax if you're using PHP already. It's simpler and more reliable, if you have it available and generally know how to use it.
Just see the information here:
http://php.net/manual/en/function.include.php
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Paulod (02-16-2014)
If you do want to load content from a div, jQuery has a method for that, see:
http://api.jquery.com/load/
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Paulod (02-16-2014)
I've created about 20 php articles with includes for footer etc. Also 20 php pages of the same names with content div only (in another folder called content_only). But ideally I should delete that folder so I only have to maintain the php with included modules.
I switched from 'dd ajaxtabs' (http://www.dynamicdrive.com/dynamici...tent/index.htm) to 'dd drop tab menu' (http://www.dynamicdrive.com/dynamici...roptabmenu.htm) because I need drop downs and ajaxtabs has none. I've a new question for dealing with that called "'selected' tab is not given a class of 'selected' when using ajax"
But I still need it to load fast because it's for a project based in Tanzania where I'm told the internet is excrutiatingly slow. So I'm trying ajax & php as the front, with fallback to individual php pages with html imported by php's 'include' method. The theory is that by including, e.g. 'footer.html', in some_article.php I can then use jQuery to on a frontpage, index.php, to load in the #content div only and avoid loading all the includes. This is mostly new territory for me so I am open to any ways of getting faster loading times, better usability etc..
Some things I would like to learn:
- when grabbing an external div, does jQuery's 'load'(http://api.jquery.com/load/) actually load the whole document and strip the irrelevant parts, or does it only load that div? How can I test for this?
- will jQuery's 'load' strip out the php includes also? I read through that page and it said that scripts are stripped out in this case only (not for when loading the whole document). I'm hoping that means it will strip out the php includes also? That way I hope to make it fast and maintainable.
Thanks
Bookmarks