Welcome, Guest
Username: Password: Remember me

TOPIC: AJAX - How to

AJAX - How to 27 Mar 2012 04:52 #1736

  • andypooz
  • andypooz's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 2
  • Karma: 0
Have you got any code examples that might help us achieve this using AJAX? I'd really like to do this but need a few hints to get started. Even if it's not specific to j-cook, but how this can be done within any joomla component
The administrator has disabled public write access.
The following user(s) said Thank You: edwardcox

Re: AJAX - How to 05 Apr 2012 19:06 #1916

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I don't have lot of time to make a tutorial, but I can furnish some clues :


It is always good to use a JS framework to do this.

I personaly use MooTools Request Class, but it is maybe not the best.


Then, serialize your datas in JSON in order to transfert any kind of Object structure.

in PHP json_encode / json_decode
In JS : Use your framework to encode/decode


In your view file, don't call the template.
Return your serialized object/answer in a exit()

example :
exit(json_encode($myObject))

And in JS, you read the result and unserialize the string in object.

It is really easy, when you understood.

The most boring is the error and timeout managements.

Notice that we are working in asynchronous, so you must write your JS code in callback functions of your AJAX requester class.

Not sure to be very clear.
Coding is now a piece of cake
Last Edit: 05 Apr 2012 19:12 by admin.
The administrator has disabled public write access.
Time to create page: 0.093 seconds

Get Started