Wednesday, January 18th, 2006
Moo.ajax: 1.3kb for all your asynchronous needs
<p>
Valerio Proietti, the creator of Moo.fx, has now created a micro library for Ajax, moo.ajax.
I noticed many of you requested if it would have been possible to use the full prototype, instead of the lite one I provided with the full download of moofx, to use its ajax capabilities along with the effects. Sure you can, but wouldn’t it be cooler if there was a more lightweigt one?
Just to continue my mission in small javascripting, I have arranged this moo.ajax, in just 1.3kb of uncompressed sweetness.
read more for instructions, or download the script. As always, any comments/corrections/suggestions are highly appreciated.
moo.ajax is a very simple ajax class, to be used with prototype.lite from moo.fx. It’s roughly based on the prototype one, so their usage are very similar.
The request
to make any request just call
new ajax(url, options);The options
- method: choose either post or get. The default is post.
posyBodypostBody: if you choose post as method, you can write parameters here.- onComplete: a function that will be fired when your request is complete. The request object will be passed as a parameter of the function.
- update: an dom element or an element’s id. This element will be filled with the request’s responsetext.
An example
This will call my script.php via post, setting as parameter sleep=3. When the request is complete I want an alert with the response text, and I want an element to be updated with the responsetext as well.
new ajax ('sleep.php', {postBody: 'sleep=3', update: $('myelementid'), onComplete: myFunction}); function myFunction(request){ alert(request.responseText); }
Related Content:











As the moo-comments are closed, I’ll pester you with my opinion:
I really like moo, and although I don’t know about many other (successful) Ajax libraries, besides a little bit of prototype and dojo, I think moo.fx can play with them.
Now when will I find the time to check out moo.ajax…
The beauty of the moo libraries is that they’re so darn simple and super-small. I may not have been using dojo quite right, but my page load times were unacceptable.
[...] Moo.ajax: 1.3kb for all your asynchronous needs [...]
[...] Ajaxian » Moo.ajax: 1.3kb for all your asynchronous needs [...]
Some one know whi the fade effect don’t work (for me) on IE?. This is the url http://www.purocss.com, the form must fadeout on submit. In firefox work great! :)
[...] http://ajaxian.com/archives/mooajax-13kb-for-all-your-asynchronous-needs [...]
Moo.ajax: 1.3kb for all your asynchronous needs
TrackBack From:http://www.blogjava.net/martinx/archive/2006/01/20/28723.html
Moo.ajax: 1.3kb for all your asynchronous needs
TrackBack From:http://www.blogjava.net/martinx/archive/0001/01/01/28723.html