Results 1 to 6 of 6

Thread: Ajax to pull php require() files

  1. #1
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax to pull php require() files

    I'm trying to use AJAX based tabs like the ones found at DD and I would like to pull the data from a php require(blah.php) as the content inside the tab container. Currently I use DHTML to show/Hide the <div>'s but ajax would be a better use of bandwidth to keep the initial information down in size unless the extra information was needed. I am unsure tho how to do that, or if it is even possible to load a require after the rest of the page has already loaded.

    Has anyone tried anything like this or have any ideas?

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    If the code in the required file depends on code in the original file, then it can't be done. If you still want to try. Google can help

  3. #3
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by blm126
    If the code in the required file depends on code in the original file, then it can't be done. If you still want to try. Google can help
    ya i checked google for this (although this would hardly be beginner ajax stuff) and no one seems to have done it either so I figured the latter would be the problem.

  4. #4
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    No, you don't understand. PHP is serverside. AJAX is (mostly) client side. If your PHP file you would like to display depends on code on the original page, then it can't be done (easily). If it doesn't then this is standard(inaccessible) AJAX.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Depends how often the content in the tabs will change, and how big it is. If it's not likely to change more than, say, once an hour, and it totals less than, say, 512K (not including images), there's no need to use AJAX at all. Load it directly into a <div> using PHP, then hide that <div> using Javascript, to be shown when the appropriate tab is pressed. This solves both your problems.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by blm126 View Post
    No, you don't understand. PHP is serverside. AJAX is (mostly) client side. If your PHP file you would like to display depends on code on the original page, then it can't be done (easily). If it doesn't then this is standard(inaccessible) AJAX.
    No, I do understand that. But I don't know Serverside Ajax that well, and yes the php file does depend on the original page so you did answer what I already assumed.


    Quote Originally Posted by Twey View Post
    Depends how often the content in the tabs will change, and how big it is. If it's not likely to change more than, say, once an hour, and it totals less than, say, 512K (not including images), there's no need to use AJAX at all. Load it directly into a <div> using PHP, then hide that <div> using Javascript, to be shown when the appropriate tab is pressed. This solves both your problems.
    Well that's what I already had... I was just seeing if Ajax would work for me as an alternative... but it looks like it won't so I'll just leave it as is.

    Thx

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
  •