Results 1 to 6 of 6

Thread: load content from a div

  1. #1
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default load content from a div

    Script: DD Ajax Tabs

    http://www.dynamicdrive.com/dynamici...jaxtabscontent

    I want to load content from a div in another document, rather than loading the whole document. Is this possible?

    Thanks,
    Paul

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Not really. In a very complicated way you could get the whole page then remove all of the extra content and leave only the div. But that will be difficult to implement and inefficient.

    The better solution is to set up your div to be the whole page in the first place. There are several ways to approach this, but in short you should look for a way to remove everything else from that page, either by creating a second copy of the page (with limited content) or by moving that div to a new page and including it into all pages where it is needed.

    You might want to look into a serverside language like PHP to include parts of pages within others, or server side includes (SSI), or maybe a content management system. HTML (+Javascript) will only get you so far.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I was looking to speed up a website so I've been playing around with php to include modules and I like the ease of maintenance, but the tabs were refreshing the page so I turned here to ajax.

    I'll create bicycle.html for the content only, and include it in bicycle_full.php

    From the menu in my main.php, I will link to bicycle_full.php as the default, i.e. for users without javascript.

    With ajax, I should simply load the bicycle.html like you said.

    What isn't clear to me is how to tell whether javascript is on or not, and then how to respond with either the default or the ajax?

    Perhaps if the menu link pointed to bicycle_full.php and then if javascript would replace part of the name, so it grabbed bicycle.html instead?

    I suspect it's something to do with manipulating strings and regular expressions, but I'm not that advanced just yet, maybe tomorrow! :P

    Thanks a lot for the feedback, it is very helpful to realise I was not too far from the track!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    There's almost no point at all in using Ajax if you're using PHP already. It's simpler and more reliable, if you have it available and generally know how to use it.

    Just see the information here:
    http://php.net/manual/en/function.include.php
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. The Following User Says Thank You to djr33 For This Useful Post:

    Paulod (02-16-2014)

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

    If you do want to load content from a div, jQuery has a method for that, see:

    http://api.jquery.com/load/
    - John
    ________________________

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

  7. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Paulod (02-16-2014)

  8. #6
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I've created about 20 php articles with includes for footer etc. Also 20 php pages of the same names with content div only (in another folder called content_only). But ideally I should delete that folder so I only have to maintain the php with included modules.

    I switched from 'dd ajaxtabs' (http://www.dynamicdrive.com/dynamici...tent/index.htm) to 'dd drop tab menu' (http://www.dynamicdrive.com/dynamici...roptabmenu.htm) because I need drop downs and ajaxtabs has none. I've a new question for dealing with that called "'selected' tab is not given a class of 'selected' when using ajax"

    But I still need it to load fast because it's for a project based in Tanzania where I'm told the internet is excrutiatingly slow. So I'm trying ajax & php as the front, with fallback to individual php pages with html imported by php's 'include' method. The theory is that by including, e.g. 'footer.html', in some_article.php I can then use jQuery to on a frontpage, index.php, to load in the #content div only and avoid loading all the includes. This is mostly new territory for me so I am open to any ways of getting faster loading times, better usability etc..

    Some things I would like to learn:
    - when grabbing an external div, does jQuery's 'load'(http://api.jquery.com/load/) actually load the whole document and strip the irrelevant parts, or does it only load that div? How can I test for this?

    - will jQuery's 'load' strip out the php includes also? I read through that page and it said that scripts are stripped out in this case only (not for when loading the whole document). I'm hoping that means it will strip out the php includes also? That way I hope to make it fast and maintainable.

    Thanks

Similar Threads

  1. Resolved SAG Content Scroller v1.3 - Content Does Not Load When Using AjaxSource Option
    By Zatek in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 10-31-2012, 06:17 PM
  2. Replies: 5
    Last Post: 07-19-2010, 10:04 AM
  3. Refresh the content on each load with Featured Content Glider
    By henkedk in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 03-17-2009, 12:32 PM
  4. Load an Ajax Tab Content inside another tab content
    By Vibam@all in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-05-2007, 03:20 PM
  5. Replies: 4
    Last Post: 01-27-2006, 11:51 AM

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
  •