views:

46

answers:

1

I'm loading content into several divs with

ajax_loadContent

<div class="content"><div class="container" id="contents2"><!-- Empty div for dynamic content -->Loading content. please wait...</div><script type="text/javascript">ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');&lt;/script&gt;&lt;/div&gt;

Basically, I don't want to load anything until the user clicks on the links I have specified to load content into these instances, please help! Right now, I'm loading a blank file to show nothing in the div.

+1  A: 

Your function is being called inside the <script> tags, so it's going to run as soon as the javascript is loaded.

Using jQuery, run the function only when elements with the id "link_id" are clicked.

$(document).ready(function() {
    $("#link_id").click(function() {
        ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');
    });
});

or using a non jQuery method:

<a href="javascript:ajax_loadContent('contents2','http://www.thewebsite.com/blank.php')"&gt;clickme&lt;/a&gt;

or

<a href="" onClick="ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');return false;">click me</a>
jjclarkson
why do you think he is using jquery?
zerkms
do you mean non jquery? ;-) and why it's not at onclick="" ?
zerkms
Hey guys, thanks for the reply, I'm not using jQuery unfortunately :( I should but this is a buddy's old site, I believe using http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-content
Reden
to load content the page's already using <a href="#" onclick="ajax_loadContent('contents2','http://www.thepage.com');return false" />Load this into box</a>
Reden