PDA

View Full Version : AJAX with rollover buttons loading text into a DIV


liverfarm
03-12-2010, 02:44 AM
So after my last thread asking about some DIV problems, ive been re directed to using AJAX, which seems to be exactly what im after.

Im using a snippet of code to call a txt. file to a div when a button is clicked. This works fine but when i decide to change the button to a rollover image instead, the text loads and unloads in about a second.

Any ideas how i can get it to stick until the next rollover button is clicked?

Here is the AJAX code im using:
function loadXMLDoc(url)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
document.getElementById('bodytext').innerHTML=xmlh ttp.responseText;
}


and this is my rollover button code:
<a href="" onclick="loadXMLDoc('home.txt')" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','../assets/homeBtnO.png',1)"><img src="../assets/homeBtn.png" alt="home" name="home" width="37" height="14" border="0" id="home" /></a>

thanks in advance

liverfarm
03-16-2010, 03:41 AM
*bump*
haha sorry, just really need some help on this. Anyone used AJAX before?

domedia
03-16-2010, 03:09 PM
Moved to JS, hopefully more luck here.