Sunday, January 08, 2006

The pleasure of cracking something

Made AJAX to work with our libraries. It is simple,

  1. You create an xml-http object (Javascript)
  2. Call a function on change/blur event of the source field which connects to the server with the source field id and fetches the xml formatted values for the destination fields. (Javascript)
  3. Write a file in the server to generate values for destination fields based on the source id received from the request and send them in xml form. (PHP)
  4. Assign the values to the destination fields in the client (Java Script)
To do this,
  1. Created an ajax.inc files to include the javascript code in any page as a function call.
  2. Pass the variables (url of the responding php script, source field, destination fields as an array) to the function.
  3. Modified the generateSelectMenu code and input tags to include an id tag.
  4. That is it, it works like a charm.
Combining Smarty and AJAX we have a rich client, easy to program in the browser.

I borrowed the ideas from the above tutorial for the AJAX implementation.

It is a gift to understand complex concepts and it is a greater gift to explain to others in understandable terms. Thanks to Bill Bercik for his time/effort in writing the tutorial. http://www.webpasties.com/xmlHttpRequest/

0 Comments:

Post a Comment

<< Home