Results 1 to 5 of 5

Thread: ajaxpage vs. ajaxinclude

  1. #1
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ajaxpage vs. ajaxinclude

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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.

  4. #4
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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/dynamici...axincludes.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/dynamici...jaxcontent.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.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by maybaum View Post
    An alternative way is to use ajaxpage (http://www.dynamicdrive.com/dynamici...jaxcontent.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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •