Published on 2005-08-28 12:36:19

I don't know how I've forgot to mention this toolkit here, while it was the first one that I was using, Toxic makes very simple to call PHP methods from javascript. Callbacks can have a "soft" or "hard" binding making it easy to call calbacks in javascript from PHP. Even exceptions thrown in PHP are tranferred and can be caught as normal in javascript. For example

myUser.bindParams('save', 'User_id', 'User_login', 'User_firstname', 'User_lastname', 'User_email', 'User_group', 'User_age'); ... myUser.execute('save'); // The PHP code class User { public function save($id, $login, $firstname, $lastname, $email, $group, $age) { if ($id == null || $id == 0) { // Code to save user return $newUserId; } throw new Exception("Updating a user is not implemented"); } }

Toxic license is "free for all purposes except if you try to charge for Toxic itself". You can download Toxic 0.1 AJAX Toolkit from here.


Related Entries

Member of the PHP Magazine Network, Copyright (C) 2005-2008 phpmagazine.net All Rights Reserved