PDA

View Full Version : Dynamic Ajax Content loading a file upon file load, rather than a link.



TrueKnight
01-24-2008, 05:17 PM
1) Script Title: Dynamic Ajax Content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.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?

ddadmin
01-25-2008, 06:10 AM
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:


<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").

TrueKnight
01-25-2008, 04:20 PM
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??

ddadmin
01-25-2008, 09:25 PM
Firstly, the DIV container should proceed the call to load an Ajax page inside it, so:


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

williamstam
05-12-2008, 10:10 AM
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