[FX.php List] Multiple AJAX with 1 JavaScript function?

Joel Shapiro jsfmp at earthlink.net
Tue May 22 18:28:10 MDT 2007


Hi all

I'm pulling a list of course-offering titles via FX.  For each  
returned title, I want to have an AJAX (LAJAX) link to "Check for  
upcoming classes".  I'm currently having the php generate one  
'serialized' JavaScript function for each returned course-offering  
(which works fine), but I'm wondering if there's a way to have just  
one JavaScript function and somehow use unique parameters for each  
result and respective DIV.

Here's what my generated code looks like:
---------------------------------------------
function FindUpcoming0() {
	if(LAJAX.state() == 4) {
			document.getElementById('getDIV0').innerHTML=LAJAX.result();
		} else {
			document.getElementById('getDIV0').innerHTML="Fetching data ... "  
+ LAJAX.state();
		}
}

function FindUpcoming1() {
	if(LAJAX.state() == 4) {
			document.getElementById('getDIV1').innerHTML=LAJAX.result();
		} else {
			document.getElementById('getDIV1').innerHTML="Fetching data ... "  
+ LAJAX.state();
		}
}

// ETC...
---------------------------------------------

The generated links are:
<a href="javascript:LAJAX.get(url,FindUpcoming0,'id=123');">
<a href="javascript:LAJAX.get(url,FindUpcoming1,'id=456');">
etc...

I'm looking for some kind of generic FindUpcoming() function that I  
could pass a '13' to, so that the results would display in DIV13.   
I've tried a few ways but couldn't get anything to work.  Is this  
possible, or do I really need a unique js function for each call?

TIA,
-Joel


More information about the FX.php_List mailing list