PDA

View Full Version : ajaxpage vs. ajaxinclude



maybaum
03-18-2007, 07:03 PM
Hi,
I have used both ajaxpage and ajaxinclude successfully - thanks!

My question is: Are there circumstances where one is better than the other?

I am trying to write up some advice for using them, and I am unclear about this point.

Thanks,
--Jon Maybaum

jscheuer1
03-18-2007, 07:26 PM
If you want much input on this, your chances would increase if you provide links to the scripts that you are talking about.

Also helpful, if you have it, would be some idea of the type(s) of things you would be using these scripts for.

Without looking at the scripts I would say that much would depend upon the the actual use that either is being put to, as to how appropriate either might be to a given task.

ddadmin
03-19-2007, 01:57 AM
Like John said, please include links to the two scripts in question. ajaxpage() and ajaxinclude() are two functions used by two different scripts on DD (I can't remember which). But you'll need to be more specific when asking your question. "Are there circumstances where one is better than the other?" is way too general, and that's even if we knew which two scripts you're talking about. :)

maybaum
03-19-2007, 11:07 AM
OK, sorry for the lack of detail. Here is more:

I am trying to provide advice for people (who know almost no JavaScript) so that they can include the contents of a "child" page into the flow of a "parent" page, without using an IFrame. It appears to me that the simplest script at DD to do this is ajaxinclude (http://www.dynamicdrive.com/dynamicindex17/ajaxincludes.htm), which synchronously writes the "child" content wherever the script is placed. A note there says:

"the included file MUST be from the same domain as the page including it due to security limitations with this feature"

Is this limitation necessary, for some reason, or is it a choice of the script author?

An alternative way is to use ajaxpage (http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm), which stuffs the included content into a DIV. This appears to do the insertion asynchronously, and requires that the target DIV exist or be created by the user. Unlike ajaxinclude, this script can include content originating at other hostnames. Also, ajaxpage can use loadobjs() to load CSS and other JS files.

Since my objective is to provide th most dead-simple recipe for non-programmers, it seems to me that ajaxinclude is preferable over ajaxpage, expect when the included content comes from a different server. Have I missed anything important in this analysis?

Thanks.

jscheuer1
03-19-2007, 12:50 PM
An alternative way is to use ajaxpage (http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm), which stuffs the included content into a DIV. This appears to do the insertion asynchronously, and requires that the target DIV exist or be created by the user. Unlike ajaxinclude, this script can include content originating at other hostnames. Also, ajaxpage can use loadobjs() to load CSS and other JS files.

Wrong (from the demo page for the script that uses the ajaxpage function):


:: Dynamic Ajax Content
Author: Dynamic Drive

Note: Updated Dec 14th, 05' with instructions on using a SELECT menu to load the links.

Description: This script uses Ajax to enable you to load external pages into a DIV without having to reload the browser or use IFRAMES. If your external pages reference any external .css or .js files for styling, this script can also load and apply them to the page on demand.

Note: Due to security limitations, the external pages loaded must be from the same domain as the encompassing page. Any external .css and .js files associated with these pages, however, can be from any domain.

Demo (Load an external page or s . . .

This limitation in BOTH scripts is due to security restrictions imposed by browsers to prevent phishing and other types of abuse. These restrictions prevent one domain's scripts from interacting with another domain's content.

In essence, the two scripts are the same. One (Dynamic Ajax Content) simply has a more involved back end and additional options provided by the loadobjs function.

There really isn't any simple substitute for iframe or frames when content from another domain is required. Even those methods are limited in what they can do because of similar security restrictions. In the case of frames/iframes though, the restrictions only prevent interacting with the external page(s) via javascript. In fact, this is the same set of restrictions. The Ajax scripts 'get' the pages they get by interacting with them using javascript.