Results 1 to 5 of 5

Thread: Dynamic Ajax Content Help

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

    Default Dynamic Ajax Content Help

    Hi,

    I am currently using the script mentioned above ( http://www.dynamicdrive.com/dynamici...jaxcontent.htm )

    And I am using this syntax to load my content

    <script type="text/javascript">
    ajaxpage(rootdomain+'/v3/bin/current.php','right')
    loadobjs(rootdomain+'/v3/main.css')
    </script>
    <div id="right"></div>

    Obviously the CSS is not loading and IE reports an error as "object expected"

    I guess I am missing a semi-colon somewhere I guess or the above code is just plain wrong. Can someone please assist me with this?

    Thanks!

  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

    You can try:

    Code:
    <script type="text/javascript">
    ajaxpage(rootdomain+'/v3/bin/current.php','right');
    loadobjs(rootdomain+'/v3/main.css');
    </script>
    But I think you may need:

    Code:
    <script type="text/javascript">
    onload=function(){ajaxpage(rootdomain+'/v3/bin/current.php','right');
    loadobjs(rootdomain+'/v3/main.css');
    }
    </script>
    Even that won't work, or will cause other problems, if there are other onload events in the body tag or scripts on the page. A quick check of the script appears to have none of these but, I may have missed something. Also, I have no idea if you are running other scripts on your page. There are workarounds if onload conflict is at issue. Please provide a link to you page.

    This may work as well:

    Code:
    <div id="right"></div>
    <script type="text/javascript">
    ajaxpage(rootdomain+'/v3/bin/current.php','right');
    loadobjs(rootdomain+'/v3/main.css');
    </script>
    - John
    ________________________

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

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

    Default

    Thanks for the info however it is not applying CSS to the included page only unfortunately. It is applying it to the entire page

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

    Default

    It will do that. The only way around it is to edit the stylesheet and put "#right" before each selector.
    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!

  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 Twey
    It will do that. The only way around it is to edit the stylesheet and put "#right" before each selector.
    Twey is absolutely correct about this. And, once you have done that, there is no reason you cannot hard code the stylesheet to the 'top' page and dispense with loadobjs() altogether. For finer tuning (having the styles only apply to certain ajax loaded content), you would need to provide a class or id for all objects on the desired content pages and edit your selectors and ajax markup accordingly. What the loadobjs() function does is add the call for the script or stylesheet to the head of the 'top' page. The result is little different than if the stylesheet was hard coded onto the 'top' page. There are some minor variations in this as it is applied to scripts but, they are minor. With stylesheets, it is virtually the same as having the stylesheet linked to the 'top' page to begin with.

    The script's author explains in another post that this facility was added to these AJAX scripts as a convenience, not as anything for complex effects. For that, one still needs to rely upon good old fashioned ingenuity and Twey's idea is a very good one here.
    - 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
  •