Forum Moderators: open

Message Too Old, No Replies

How do I get multiple instances of ajax or jscript to run?

on the same page?

         

netchicken1

5:21 am on Jun 19, 2007 (gmt 0)

10+ Year Member



Using Scriptaliscious...

I can get one to work OK, but if I try and get more than on on a page it only activates the last one ...
(code stript down to basics for help)

I have tried all sorts of methods....
such as
onclick="showIt('humor')"
onclick="showIt(humor)"
etc

but never can I get both working at once.

this works...
<script src="../ajax/lib/prototype.js" type="text/javascript"></script>
<script src="../ajax/src/scriptaculous.js" type="text/javascript"></script>

<body>
<SCRIPT type="text/javascript">
function showIt(humor) {new Effect.Appear('humor');}
function hideIt(humor) {new Effect.Fade('humor');}
function showIt(general) {new Effect.Appear('general');}
function hideIt(general) {new Effect.Fade('general');}
</SCRIPT>

<h2 onclick="showIt('general')">General topics - click for more</h2>
<DIV id="general" style="display:none">
<h2 onclick="hideIt('general')">Click to close </h2>
test
</div>

<h2 onclick="showIt('humor')">Humor - click for more</h2>

<DIV id="humor" style="display:none">
<h2 class="index_heading1" onclick="hideIt('humor')">Click to close </h2>
test1
</div>

</body>

colandy

11:51 am on Jun 19, 2007 (gmt 0)

10+ Year Member



AJAX should work with several calls using different objects. Although I have read somewhere that certain browsers don't like using more than 3 or 4 at a time.

It really depends on your code and as the majority of your AJAX code is hidden it will be hard for anyone to solve your issue.

I do have one application that has 6 or 7 AJAX objects running concurrently. So it really shouldn't be an issue.