I concur with Garrett in this instance. If it is a simple switch of text then pure Javascript, without Ajax, would more than suffice. If nothing else, it's almost instant, whereas with Ajax there is a natural wait time, albeit half a second. Try the following code I've wrote for you. Nothing like a little Javascript in the morning to give vigour to a sleepy soul!
HTML segment:
Code:
<body onload="TextChange.init();">
<div id="toggleDefault">
Small paragraph to be changed.
</div>
<div id="toggleHidden" style="display: none;">
Small paragraph to be shown upon click.
</div>
<br />
<a href="javascript:void(0);" id="toggleLink">Toggle</a>
</body>
Javascript segment:
Code:
<script type="text/javascript">
var TextChange =
{
init: function()
{
TextChange.State = 1;
TextChange.Default = document.getElementById('toggleDefault');
TextChange.Hidden = document.getElementById('toggleHidden');
TextChange.Link = document.getElementById('toggleLink');
TextChange.Link.onclick = function()
{
switch(TextChange.State)
{
case(1): TextChange.show(); break;
case(2): TextChange.hide(); break;
}
}
},
show: function()
{
TextChange.Default.style.display = 'none';
TextChange.Hidden.style.display = '';
TextChange.State = 2;
},
hide: function()
{
TextChange.Hidden.style.display = 'none';
TextChange.Default.style.display = '';
TextChange.State = 1;
}
}
</script>