PDA

View Full Version : Ajax Includes script problems



themilewall
01-16-2006, 01:33 AM
Hi,

Ajax Includes
http://www.dynamicdrive.com/dynamicindex17/ajaxincludes.htm

first of all, thank you for the script It has been extremely helpful, however I have encounted a problem with the Ajax Includes Script. I use the script on this page:

www.themilewall.com/maintest.htm (http://www.themilewall.com/maintest.htm)

I have included multiple html pages into a single one in order to make the content load sequentially. When I got to about seven of these:

<script type="text/javascript">
ajaxinclude("example.html")
</script>

The external pages started to squash and all the content would line up. If you scroll across the above page you can see an example of this. Any insight into why it is doing this would be immensely helpful.

Thank you for your time.

-Travis

jscheuer1
01-16-2006, 08:43 AM
Looks like you hit a 'wall' (pun intended). Actually, this is not a problem in NS8 (FF mode) but, there your measuring stick graphic below the images does not show, though the 'mile' markers do. I see what you mean in IE. This is most likely either a layout problem or some intrinsic limitation for IE. How are you setting the width of the page? Have you tried setting up a train of images that long on a plain page without includes? You might have better luck if your overall layout was a table row that you kept adding cells to.

ddadmin
01-16-2006, 03:16 PM
I noticed that you're calling the Ajax include script as follows:


<script type="text/javascript">
onLoad=ajaxinclude("section3.html")
</script>

You'll need to remove the "onLoad=" code, since this script cannot be called after the page has loaded- it needs to be called directly. I suspect this is the source of your problems...

Twey
01-16-2006, 04:06 PM
Looks like you hit a 'wall' (pun intended).Oh, dear.

themilewall
01-16-2006, 04:18 PM
thanks for responding,

Yes I have hit a wall :(! I don't think it has anything to do with the onLoad I added but now I know that it doesn't change anything so I'll take that out! It was doing its sqaush thing before I added that.

The original page was set up without an includes script, however because of it's abnormal horizontal orientation, the page loads backwards. You can see how slow the normal way is at,

www.themilewall.com (http://www.themilewall.com)

I've tried everyway of including and setting the length I could think of, Tables worked, and did not squash content, but then they overlapped and some of the content below was unclickable. Is there some sort of limit to the amount of includes you can have on one page? Thanks for the help troubleshooting!

-Travis

ddadmin
01-16-2006, 07:29 PM
Wow, you're including a lot of content dynamically. In such instances, you're really pushing the limits of doing this client side, such as by using the Ajax Includes script. BTW, using "onload" definitely won't work, which you still have one remaining on your page.

Back to the issue though, do you have access to something like SSI (server side includes) or PHP on your server> If so, using server side to include the content instead of forcing the user browser to do this work would definitely be much better here.

themilewall
01-16-2006, 08:05 PM
Yes I have access to both SSI and PHP, and I like PHP a heck of alot better than JavaScript, but how can I do this same thing with php? I really am not sure how SSI works at all doesn't it use JavaScript as well?

I wanted to make the page load piece by piece, or at least have the front part of the page load first and then have the rest load, which is why I thought the synchronous Ajax would help, can I accomplish this same thing with a <?php include 'example.html' ?>?

Thanks again for the help, I really appreciate it, if you have a small logo I would be more than happy to add it to the wall.

Thanks,

Travis

Twey
01-16-2006, 08:19 PM
I wanted to make the page load piece by piece, or at least have the front part of the page load first and then have the rest load, which is why I thought the synchronous Ajax would help, can I accomplish this same thing with a <?php include 'example.html' ?>?Yes.
SSI stands for Server-Side Includes, and so obviously doesn't use a client-side language like Javascript. I think to include a file using SSI is something like
<!-- #include file="example.html" -->I'm probably wrong.

ddadmin
01-16-2006, 08:32 PM
Is the page itself PHP or SSI enabled? For example, is the extension .php or .shtml?

You can't load and display content sequentially using any server side language. However, one solution is to use a script like Sequential Content loader (http://www.dynamicdrive.com/dynamicindex17/seqreveal.htm) and inside the DIV tags, embed the external content using PHP or SSI...

Twey
01-16-2006, 08:55 PM
You can't load and display content sequentially using any server side language.Wrong.
<?php
for($i=0;$i<=256;$i++) echo(" "); // Output 256 spaces for Internet Explorer.
include($file1); // Include the file.
ob_flush(); // Flush any extra output buffer that may be running.
flush(); // Flush the main (top-level) output buffer.
?>It's not too reliable, but it's possible.

themilewall
01-16-2006, 09:08 PM
I've just made the main page www.themilewall.com (http://www.themilewall.com) a .php extension and I used <?php include 'example.php' ?> so it works but still not sequentialy at this point

@Twey, sorry but I'm a dolt when it comes to programming I only know enough php to just get by, could you explain the lines

for($i=0;$i<=256;$i++) echo(" "); // Output 256 spaces for Internet Explorer.
ob_flush(); // Flush any extra output buffer that may be running.
flush(); // Flush the main (top-level) output buffer.

and @ ddadmin With the sequential content loader you showed me, all the files would have to download to the user first right? I don't really want to hide anything so much as make the page load at different times. I just shudder when I think about my bandwidth usage when the status bar says (2358 items remaining :eek: )

Right now it seems to load okay, and the menu at least loads first which is good. Thanks again guys you've been an enormous help!

Twey
01-16-2006, 09:14 PM
I just shudder when I think about my bandwidth usage when the status bar says (2358 items remaining)You're still downloading all that, you realize :) It just doesn't say so.

for($i=0;$i<=256;$i++) echo(" "); // Output 256 spaces for Internet Explorer.IE (at least some versions) doesn't start rendering the page until 256 bytes of data have been downloaded. So, we output 256 spaces to force it.
ob_flush(); // Flush any extra output buffer that may be running.An output buffer is something that stores output before sending it to the browser or another output buffer higher up. This causes it to send all its data now.
flush(); // Flush the main (top-level) output buffer.Same, but for the upper-most output buffer: causes its contents to be sent to the browser.

ddadmin
01-17-2006, 12:46 AM
Wrong.
<?php
for($i=0;$i<=256;$i++) echo(" "); // Output 256 spaces for Internet Explorer.
include($file1); // Include the file.
ob_flush(); // Flush any extra output buffer that may be running.
flush(); // Flush the main (top-level) output buffer.
?>It's not too reliable, but it's possible.

Hehe ok I know better now than to make a statement in front of Twey.

To the OP, the best solution IMO is to use a mix of PHP and DHTML, such as PHP for inclusion and the sequential content loader for displaying. Like Twey said, you're going to have to download that content (use the bandwidth) anyway. Of course, if you can streamline and reduce the actual content to download, that would solve even more problems.

themilewall
01-17-2006, 01:31 AM
Ok I'll try that in addition to the PHP, I'll have to think of some other plan to sort out the loading issue, I'll probably have to rearrange the way my site works to do that. Thanks again for all the help you've both provided!

Travis

Twey
01-17-2006, 04:27 PM
Hehe ok I know better now than to make a statement in front of Twey.Oh, Mike's still the master there :p

if you can streamline and reduce the actual content to downloadI see you're using Apache. Try the mod_deflate (http://httpd.apache.org/docs/2.0/mod/mod_deflate.html) module.