Results 1 to 9 of 9

Thread: How to use Javascripts in AJAX ??

  1. #1
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy How to use Javascripts in AJAX ??

    My friend said me that the output of an AJAX page is plain html

    I used tab in my webpage using


    http://www.dynamicdrive.com/dynamici...tent/index.htm

    but i cany use any of those javascripts inside those pages....

    Someone help me please in this matter.

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    What problem are you having? If possible, please post a live example URL. Your above post leaves us with absolutely no way to help you.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. #3
    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

    The simple way would be to use the script's iframe method to load pages with javascript on them.
    - John
    ________________________

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

  4. #4
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am using tabs in my page, i mean AJAX tabs to view external pages into this current page . But actually whats happening is my External pages have JavaScripts inside them.These are not functioning when viewed from the main page. People asked me to use iframes instead of AJAX tabs. But Is there any way to continue with AJAX instead of iframes but still enable teh javascripts

    thanking you

  5. #5
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    I can think of a way, but it uses kinda heavy PHP. (See "Advanced escaping" at http://www.php.net/manual/en/language.basic-syntax.php.)
    Code:
    <?php
    $ajax = isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 'true';
    if($ajax){
        ?>
    <html>
        <head>
            ...
        </head>
        <body>
            Anything that repeats across pages or shouldn't be received by AJAX for some other reason.
        <?php
    }
    ?>
            All the stuff you want to send whether AJAX is being used or not.
    <?php
    if($ajax){
        ?>
        </body>
    </html>
        <?php
    }
    ?>
    Now when you request that page, add ajax=true to the query string (for either GET or POST).
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  6. #6
    Join Date
    Jul 2008
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i have the same problem. When I open an html into a <div> content, if the html have a javascript code it's not run. why?
    here is an example:
    Enter to http://www.guif.net/menu/hola.html (this is a correct screen)
    ..And now, go to http://www.guif.net/menu/_index.html > Menú (at right, top) and click to the first link.
    wow! the hola.html file is not correctly! Why????

  7. #7
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Hmm, I apparently misunderstood the OP. I thought he was complaining that the head tag shouldn't be included.

    I think this is due to the youth of AJAX - browsers haven't fully adapted to it. But have you tried receiving the JS as a separate file and eval'ing it?
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  8. #8
    Join Date
    Jul 2008
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    this is an answer for me?
    I think that my problem is that the DIV don't open a javascripts files because if I open directly the file it's open correctly....

  9. #9
    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

    Ahem . . .

    Quote Originally Posted by jscheuer1 View Post
    The simple way would be to use the script's iframe method to load pages with javascript on them.
    - 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
  •