[FX.php List] [Poll] Which ajax implementation do you use?

Joel Shapiro jsfmp at earthlink.net
Fri Oct 5 11:51:24 MDT 2007


Hi Andy

Thanks for the reply.

Yes I do know that a single LAJAX function can reference multiple  
DIVS -- I tried to state that in my last post.

Unfortunately, while experimenting with the jTip tooltip plugin, the  
structure of the code required to have one link display a tooltip on  
hover and then go to a different link on click was a bit awkward  
(something like <a href="tooltipdata.php?&amp;link=goToOnClick.php">)  
and I found that using two javascript calls/functions after the  
"link=" didn't work (i.e. <a href="tooltipdata.php? 
$amp;link=javascript:divID='xyz';LAJAX.get(url,edit,{parameters);">  
did *not* work.)  This is why I'd mentioned creating multiple LAJAX  
functions as a second option.

My point, though, was that each link in LAJAX has to reference its  
own specific DIV ID (via PHP and $currentRecord -- I hadn't meant  
that they had to be hard-coded); while in jQuery the link itself (as  
could be viewed in ViewSource) doesn't need to reference any DIV at  
all.  Certainly it's not much work to get PHP to spit out the current  
DIV ID, but what I like about jQuery is that it provides a way to  
abstract the interface from the data... in other words, up top in my  
<script> section of my page is where I put the code telling how, when  
and where to put triggerable events and how, when and where to return  
my results, and my data output can remain more straight-forward  
data.  I'm probably not explaining this well since it's all still so  
new to me, but it really is pretty revolutionary in how it's getting  
me to think about coding for the web.  In fact, I can now have my  
tooltip links clickable without having to use the awkward jTip link  
structure, just by using standard jQuery code.

Best,
-Joel
p.s. I don't believe you need to have two separate vars like in your  
LAJAX example below.  Just using targetDiv everywhere instead of  
updateDIV works for me, without needing to set one var to another,  
nor needing to use "document.targetDiv" (thanks to Kevin Becker on  
this list back in May :)


On Oct 4, 2007, at 6:47 PM, Andy Gaunt wrote:

> Joel,
>
> You do not have to write multiple functions for LAJAX to target  
> specific divs.
>
> If you have a function as such:
>
> var targetDiv = null;
> 	
> function updateDynamic()
> 	{
> 		var updateDIV = document.targetDIV;
> 		if(Lajax.state() == 4) {
> 			document.getElementById(updateDIV).innerHTML=Lajax.result();
> 		} else {
> 			document.getElementById(updateDIV).innerHTML="Please wait...";
> 		}
> 	}
>
> Your LAJAX request could then be:
>
> <a href="javascript:document.targetDIV='update<?php echo  
> $currentRecord; ?>';Lajax.post(url,updateDynamic, 
> {parameters};">Link text here</a>
>
>
> With the targetDIV being a unique DIV ID and the Lajax.post or  
> Lajax.get targeting that div. One function to cover all your bases.
>
> Hope this helps.
>
> Andy Gaunt
> T: 321-206-3658
> andy at fmpug.com
> http://www.fmpug.com
>
> FMPug: A Developer's best Friend!
>
>
> On Oct 4, 2007, at 3:42 PM, Joel Shapiro wrote:
>
>> Hey Gjermund
>>
>> I started using LAJAX because it was so ready-to-use without  
>> having to know much about JavaScript or AJAX.
>>
>> I've recently been getting into jQuery, and just discovered how to  
>> do something that's really pushing me to use jQuery more:
>>
>> In LAJAX, you need to specify the <div> that the callback will go  
>> to.  In my current project, I have many divs (cells in a table)  
>> that can each get refreshed through an AJAX call to the DB.*  With  
>> LAJAX I needed to either reference by ID the specific DIV in each  
>> link, or create multiple LAJAX functions -- one for each div,  
>> (which I might have had to do due to the limitations of a jQuery  
>> plugin I was using).  Anyway, jQuery has a command called "this",  
>> which acts on the DOM** element that triggers the action -- so you  
>> don't need to specify WHERE to do an action... jQuery knows  
>> exactly where via its use of "this".  On top of that, there are  
>> various methods to 'traverse' the DOM, such as "parents" which  
>> goes up the hierarchical ladder of the DOM starting at the "this"  
>> element and stopping at whatever element you specify.  For instance:
>>
>> I've got something like:
>>
>> <div class="cell">
>>   <div class="year">
>>     <ul class="year">
>>       <li>
>>         <a>xyzlink</a>
>>       </li>
>>     </ul>
>>   </div>
>>   <div class="fall">
>>      (etc.)
>>   </div>
>> </div> <!-- end of "cell" div-->
>>
>> With the jQuery line:
>>    $(this).parents(".cell").load("ajaxpage.php");
>> I can have jQuery load ajaxpage.php into the outside <div> that is  
>> surrounding THAT PARTICULAR LINK (<a>) that triggered the call.  I  
>> don't need to specify that cell by any ID.
>>
>> *My setup is diffferent than the LAJAX sample, which loads results  
>> into a DIFFERENT div.  Mine reload into their same divs.
>> **DOM in layperson's terms are the base html elements: <html>,  
>> <body>, <p>, <div>, <span>, <a>,  <ul>, <li>, etc.
>>
>> Granted, it's taken me a little time to understand how jQuery  
>> works, but it is really cool... and I'm only just beginning.
>>
>> Hope that's helpful,
>> -Joel
>>
>>
>> On Oct 2, 2007, at 4:49 AM, Gjermund Gusland Thorsen wrote:
>>
>>> I use LAJAX( http://www.fm-synergy.com/page1/page1.php )
>>>
>>> I have not really looked at any of the other implementations...
>>>
>>> Are there anyone who compared them before you started?
>>>
>>> ggt667
>>>
>>> On 10/2/07, Steve Winter <steve at bluecrocodile.co.nz> wrote:
>>>> Prototype - http://www.prototypejs.org/
>>>>
>>>> Cheers
>>>> Steve
>>>>
>>>> -----Original Message-----
>>>> From: fx.php_list-bounces at mail.iviking.org
>>>> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of  
>>>> Gjermund Gusland
>>>> Thorsen
>>>> Sent: Tuesday, 2 October 2007 8:54 a.m.
>>>> To: FX.php Discussion List
>>>> Subject: [FX.php List] [Poll] Which ajax implementation do you use?
>>>>
>>>> Which ajax implementation do you use?
>>>>
>>>> The subject says it all.
>>>>
>>>> ggt667
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>>
>>>> No virus found in this incoming message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.5.488 / Virus Database: 269.13.37/1042 - Release  
>>>> Date: 1/10/2007
>>>> 6:59 p.m.
>>>>
>>>>
>>>> No virus found in this outgoing message.
>>>> Checked by AVG Free Edition.
>>>> Version: 7.5.488 / Virus Database: 269.13.37/1042 - Release  
>>>> Date: 1/10/2007
>>>> 6:59 p.m.
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list