Advanced Search

Results 1 to 5 of 5

Thread: Dynamic Ajax Content loading a file upon file load, rather than a link.

  1. #1
    Join Date
    Jun 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamic Ajax Content loading a file upon file load, rather than a link.

    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem: How can I have this Script load a file upon being loaded, rather than having it load when selecting a link?

    I know I could use the AJAX Include Script...but I cannot load/attach a specific CSS file with that script. That's why I want to use the Dynamic Ajax Content script. Is there a way to do this? Or is there another script that would work better?

    Is that as clear as mud?

  2. #2
    Join Date
    Aug 2004
    Posts
    9,863
    Thanks
    3
    Thanked 960 Times in 949 Posts
    Blog Entries
    15

    Default

    Yep. Per the following snippet on the script page:

    You can even load an external page without requiring the click of a link, by calling the function directly:

    Code:
    <script type="text/javascript">
    ajaxpage('test.htm', 'rightcolumn') //load "test.htm" into "rightcolumn" DIV
    </script>
    Make sure you're calling the above following the DIV it's loading the ajax page into (in this case, "rightcolumn").

  3. #3
    Join Date
    Jun 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok...I used that script and was able to get my file to load.

    But, when I try to load the css files with it the file will not load. Suggestions?

    Here's how it looks when it works:

    <script type="text/javascript">
    ajaxpage('content.html', 'pagecontainer')
    </script>

    <div id="pagecontainer"></div>


    Here's how it looks after adding the css files in:

    <script type="text/javascript">
    ajaxpage('content.html', 'pagecontainer')
    loadobjs('../css/indexPages-alt.css', '../css/contentPages.css')
    </script>

    <div id="pagecontainer"></div>


    Is this done correctly??

  4. #4
    Join Date
    Aug 2004
    Posts
    9,863
    Thanks
    3
    Thanked 960 Times in 949 Posts
    Blog Entries
    15

    Default

    Firstly, the DIV container should proceed the call to load an Ajax page inside it, so:

    Code:
    <div id="pagecontainer"></div>
    
    <script type="text/javascript">
    ajaxpage('content.html', 'pagecontainer')
    </script>
    Also, by:

    But, when I try to load the css files with it the file will not load. Suggestions?
    Do you mean the CSS file doesn't load, or the ajax page as well? If the former, try specifying an absolute URL to the CSS file, ie: http://mysite.com/css/indexPages-alt.css.

  5. #5
    Join Date
    Jan 2008
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    basicaly its asif the loadobjs('../css/indexPages-alt.css', '../css/contentPages.css') part doesnt work... the page loades etc but not the included js / css files

    im having the same problem

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
  •