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

Joel Shapiro jsfmp at earthlink.net
Fri May 25 17:09:04 MDT 2007


Thanks for this Michael.

It's a good head start;  methinks I've just got to start playing  
around w/ jQuery.

If, perhaps, you'd like to do an early trial run of your DevCon  
session in lovely San Francisco (closer to you than Florida!), I can  
get you a good crowd  :-)

(If not, I'll post back here when questions come up.)

Best,
-Joel


On May 24, 2007, at 4:01 PM, Michael Ward wrote:

> Hi Joel,
>>
>> I'm afraid writing a wrapper is beyond me at the moment.  What  
>> kind of additional coding of AJAX calls would I need to do if I  
>> didn't use a wrapper like LAJAX?  (i.e. what is LAJAX doing?)
>
> You shouldn't need to write the wrapper yourself.. there's enough  
> of that around.
>>
>> I have a new project in which I'll want to be using quite a bit of  
>> AJAX.  Any recommendations on where I can get some more not-too- 
>> complex (yet!) info?  I've certainly played with Scriptaculous  
>> examples, and looked a little at jQuery, but I've never tried to  
>> implement either on my own.  Will the issue of how to connect to  
>> FX be relatively clear from their respective documentation/ 
>> tutorials...?
>
> Probably not.
>
> The way I do it is to create my FX.php/API for PHP pages the get  
> jQuery to send an ajax call to these.  The way that is handled is  
> in the callback of the jQuery function.
>
> the syntax of jQuery handles all the triggering, sending,  
> retrieving.  FX handles the calls to the database and CSS handles  
> the layout of the returned data.
>
> eg this is an example of a how I post data to a registration page,  
> and display the returned result  (this function is called elsewhere  
> in my code):
>
> function postable () {
> // put the form data in an arrary
> 	var data = $("form#regForm").formToArray();
> //post the data to a page called registration.php	
> 	$.post("registration.php", data,
> 			 function(result){
> //show the result in the div called theForm
> 				$("div#theForm").html(result).show();
> //do some other stuff that needs to be done
> 				editables(result);
> 				initialiseBoxes();
> 			   } );
> }
>
> registration.php contains (heavily abbreviated!):
>
> <?php
>
> $action = $_POST['action'];
> require_once ('fileMakerFiles/Filemaker.php');
> require_once ('fileMakerFiles/mainData.php');
> $createDelegate = new FileMaker($database,$ip,$userName,$password);
> //are we editing or adding?
> if ( $action =="edit" )
> {
> $addDelegate = $createDelegate->newEditCommand('delegates',$_POST 
> ['recID']);
> }else
> {
>
> //create a new record using the data posted from the form
> $addDelegate = $createDelegate->newAddCommand('delegates');
> $addDelegate->setField('delegatePassword', $_POST['password']);
> }
> $addDelegate->setField('delegateFirstName', stripslashes($_POST 
> ['firstName']));
> $addDelegate->setField('delegateLastName', stripslashes($_POST 
> ['lastName']));
> <snip> setFields here</snip>
> $theDelegate = $addDelegate->execute();
> ?>
> <snip> error trapping etc</snip>
> <div id="formHeading">
> 	<h4>Please check your details. If you need to update them, change  
> the field then click "Edit Registration"<h4>	
> 	
> </div>
> <snip> all the rest of your page</snip>
>
> I'm giving a presentation and workshop of this at DevCon, but  
> that's probably too late for you.
>
> Regards
>
> Michael Ward
> --
> Head Honcho
> CustoMike Solutions
> Member, FileMaker Business Alliance
> Member, FileMaker Technical Network
> FileMaker 7 Certified Developer
> FileMaker 8 Certified Developer
> 10 Wandoo Crt
> Wheelers Hill, 3150
> ph 0414 562 501
> headhoncho at customikesolutions.com
>
>
> _______________________________________________
> 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