View Full Version : not working ajax content

05-18-2008, 10:14 PM
Switch Content Script II (icon based)


Hi, I have set this script up but i cannot get the ajaxt bit to work.
I have

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="css/new.css">

<script type="text/javascript" src="js/switchcontent.js" ></script>
<script type="text/javascript" src="js/switchicon.js"></script>

<h2>Demo 1:</h2>
<p><a href="javascript:faq.sweepToggle('contract')">Contract All</a> | <a href="javascript:faq.sweepToggle('expand')">Expand All</a></p>

<div class="eg-bar"><span id="faq1-title" class="iconspan"><img src="minus.gif" /></span>What is JavaScript?</div>
<div id="faq1" class="icongroup1">
<br />

<div class="eg-bar"><span id="faq2-title" class="iconspan"><img src="minus.gif" /></span>Difference between Java & JavaScript?</div>
<div id="faq2" class="icongroup1">
<br />

<script type="text/javascript">

var faq=new switchicon("icongroup1", "div") //Limit scanning of switch contents to just "div" elements

faq.setContent(0, 'xx.htm') //specify remote content for 1st header's content
faq.setContent(1, 'xxx.htm') //specify remote content for 2nd header's content

faq.setHeader('<img src="minus.gif" />', '<img src="plus.gif" />') //set icon HTML
faq.collapsePrevious(true) //Allow only 1 content open at any time
faq.setPersist(false) //No persistence enabled
faq.defaultExpanded(0) //Set 1st content to be expanded by default


but it doesnt seem to work. I have the two js scripts in the head. Do I need to adjust anything for the ajx to work, or do I need another js file? I cannot see a faq.setContent variable in the js files.
Thanks for any pointers.

05-19-2008, 12:32 AM
Looks right at a glance. Make sure ''xx.htm" and "xxx.htm" exist and are in the same directory as the switch content script.

If you need more help, please post a link to the page on your site that contains the problematic script so we can check it out.

05-20-2008, 09:18 PM
Hi thanks for the reply, I have the xx.htm and xxx.htm in the same folder as the js files but it doesnt seem to work.
Here is a test page
Thanks if you spot a problem.

05-20-2008, 09:26 PM
Use this as switchcontent.js as the version you have is not the correct one:


Hope this helps.

05-21-2008, 10:22 PM
Hi, I changed th script and although something works the ajax bit still doesnt. Seems funny, looks like it should work but doesnt.I am testing in ie7.