What is the best, lightweight JSON / ajax script?

I am creating a joomla plugin and want to load an array of images after the page loads. For this, I'm currently using mootools.js to call the myserver url, get a JSON response, and parse the response to javascript variables that represent each image url. It works great, but mootools.js is named appropriately as it is a real gadget in the size department.

Is there a lightweight script that will make an ajax call and parse the JSON object? Less is better.

+5
source share
5 answers

I just found a JSON parser, json2.js, on json.org, which reduces to about 3k. You basically do the standard HTTPRequest through AJAX and then pass the response text to the JSON parser to create the JSON object.

Thanks for all the answers, and I tracked them all. However, I could not get any of them small enough to compete with this approach.

+3
source

In addition to Mootools, there are many javascript frameworks that can accomplish what you are looking for. I recommend taking a look at jQuery or Prototype. They are very similar to Mootools, and the mini-Fied versions can provide the easy solution you are looking for:

http://jquery.com/

http://www.prototypejs.org/

+2
source

:

0

, MooTools , , . MooTools , , . , . , /jquery/etc.

: Request.JSON MooTools . YUI 33,8 .

0

, Net.js.

http://xkr.us/code/javascript/Net/

However, it does not support JSON parsing, but it is just one line of code, receiving a Text response and calling eval on it:

var json = eval ('(' + xhr.responseText + ')');

Disadvantages:

The timeout is not configurable. However, it is easy to change directly in the source.

There is no support for a query group with a regular handler. Each request is individual.

0
source

All Articles