PDA

View Full Version : Ajax Tabs Content script



bball2
09-17-2006, 05:18 AM
1) Script Title:
Ajax Tabs Content script

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

3) Describe problem:
Just wanted to know is there a way I can get the script to only load a certain part of an external file? ie) a specific div?

I wanted to integrate the script into wordpress so I can navigate the first 10 or so posts with this. I used to use the default tab system from dynamic drive but then my page load times were pretty bad, ie) 10 posts with images and stuff could easily go over 1/2 a meg each time, so I wanted to try this solution.

Anyways I tried a few variations including loading the whole page and using display: none; on everything cept the content but that wouldn't really display well, and I also tried using the if statement and < ! -- to comment out certain parts but then I just got a bunch of errors.

Anyways if anyone has any ideas drop off your thoughts :)

jscheuer1
09-17-2006, 05:51 AM
However you load the content, if it is "over 1/2 a meg", it will take some time to load, even if much of it is display:none;. The best method would be to break up the content into separate pages first. Then you could load it any way you like and it will not take so long. Even if there was a way to parse out a portion of a huge page for Ajax to load, it would most likely have to read the entire file each time to find the portion you want it to retrieve.

Since this sounds like a forum, why not use the forum package's server side utilities to retrieve only so many posts at a time. For instance, use this forum's search utility, set it to 'entire post' and set your search terms to something likely to retrieve a huge number of posts. It will only show so many per page.

bball2
09-17-2006, 06:20 AM
Well it's more of a blog then anything else. I could just strip everything except the content but I still want the permalinks to work (pages with comments) so that won't seem to work.

What I did before was load 10 posts on the first page at the same time, then use the regular tab content script to scroll through them but it took ages to load with a dialup connection.

jscheuer1
09-17-2006, 07:05 AM
Well, why does it have to be 10 posts? If you can break them up into 10 pages - one post per page, then using Ajax would present a savings of sorts in load time by virtue of only loading a 10th of the content at any given time. The trick still remains of having the separate pages. That's what I would like to see the server side code of your blog do, if possible. Where does it get its pages from - a database? That would be ideal, especially if said database were cached on the server. The Ajax script could possibly parse out one post from a page of ten posts but, as I said, it would probably have to cache the entire page on the client side to do so, or at the very least, read through the entire file in real time on the server to find headers. In either case, you have the server assembling the file then something reading it - much better to have the server only assemble as much data as is required at any given moment.

bball2
09-17-2006, 10:12 AM
Well I think I've gotten it fixed by using the display: none attribute. I am not all that hardcore with php or sql, so I'm not quite sure how to setup a caching system then pull the information from there. :p

One more question though, how do you get < previous | next > tags to show up with the script? ie) They would be within the section that's changing (ajaxcontentarea). So for example I have 5 pieces of information, and previous / next at the top, which loads up another page with 5 more pieces of information and different previous / next at the top. On the first page it works, but no luck after that.

jscheuer1
09-17-2006, 11:10 AM
I'd have to see it but, you should check here - just in case this is what you are looking for, it is similar if not the same:

http://www.dynamicdrive.com/forums/showthread.php?t=13070