by slothy » Sat Sep 02, 2006 12:51 pm
HI Dennis,
the easiest way I guess, if i have understood you correctly, is just to have a boolean variable, declared globally set to true
so you would have something like
var callAjax = true;
Once you have called the Ajax routine have it set to false. If you have the Ajax call in an if statement then it will only get called once.
So, taking your code below,my amendments in red :-
var callAjax = true; //globally declared
function loadProducts(e,inputObj)
{
if(!inputObj)inputObj = this;
var img = inputObj.getElementsByTagName('IMG')[0];
var numericId = img.id.replace(/[^0-9]/g,'');
var obj = document.getElementById('paneContent' + numericId);
if (callAjax)
// will be called first as global and set to true
{
ajaxpage('products.html?categoryindex=' + numericId);
callAjax = false;
return true;
else
{
// after call to Ajax ie ONE iteration callAjax will always remain false;
do something else that dosnt involve Ajax call...
}
}
hOpe it helps
ALex