Friday, January 19th, 2007

JsHttpRequest: Low level Ajax library

Category: Library, PHP

Dmitry Koterov has written JsHttpRequest a light wrapper on top of XHR and friends that features:

  • Cross-browser compatibility. Library works with IE5.0+, Mozilla 1.7+, FireFox 1.0+, Opera 7.3+, Safari (“+” means “in specified and newer versions”). By this token, code could work without ActiveX and XMLHttpRequest support (but if these capabilities are avalilable, they are used automatically).
  • File uploads from user browser to the server without page reloading.
  • Full support of PHP debug features. If server-side script fails on an error (including fatal error, e.g., call of undefined function), client-side script can handle it correctly and show diagnostics. Besides response data, it is passed the output flow of server-side script which contains PHP error messages.
  • Multi-dimensional data structures exchange (JSON analog) in client request and server responce. At that, are used the standard PHP instruments — multi-dimensional associative arrays (request data avaliable at $_REQUEST, response data may be saved to $_RESULT), as well as JavaScript standard capabilities — nested objects and properties. No XML in the level of API: you work with “native” language variables.
  • PHP session support using usual way.
  • Optimal data loading method choosing (XMLHttpRequest, Microsoft.XMLHTTP, <SCRIPT>, <IFRAME>) depending on current browser. In particular, ability to load data from foreign hosts.
  • Interface is compatible with XMLHttpRequest.


Posted by Dion Almaer at 8:30 am

3.4 rating from 53 votes


Comments feed TrackBack URI

Looks good. There is too many bloated, over the top libraries. I’ve been looking for some good lightweight examples that wont effect performance as much.

I’ll give this a shot!

Comment by Dougal Matthews — January 19, 2007

It’s been around for quite a while, actually. Just never got out from the Russian developers community of It is nice to see that we get wider recognition ;)

Comment by Vasili Sviridov — January 19, 2007

Wow, I wonder how somebody has the same ideas as me: – soon vailable in English.

Comment by Andi — January 20, 2007

I tried many times to write to Ajaxian webmaster asking to update this library description. But they haven’t updated yet. So, I post news here.

The new version 5.0 of JsHttpRequest – easy-to-use cross-browser AJAX library with uploading support – is ready. Most significant changes:

* Compatibility with Prototype. Library JsHttpRequest could be used as its server part in PHP. Even so, all additional features of JsHttpRequest (cross-browser compatibility, file uploading support, work with national charsets etc.) are still available.
* Fully automatic regression test suite. As a result – even better and guaranteed cross-browser compatibility.
* Library code is now module-based. You may switch off unneeded loading methods to shrink the JS file size. By default library supports and automatically chooses one of 3 different loading methods: SCRIPT (most cross-browser method, works when no XMLHttpRequest nor ActiveX is present); XML (native loader); FORM (for transparent file uploading). But if you do not need some of these method, you may choose a shrinked library version: JsHttpRequest-script.js (8K only!), JsHttpRequest-xml.js etc. or compose your own version manually – module separation is very clear. See JsHttpRequest/mini/
* Support and “transparent” work with any character encoding (including any national). You may write your scripts in a usual way, library will take care about everything else.
* Library code is now compressed using dojomin utility, size is lowered greatly.
* Automatical support for PHP’s native JSON functions (if available). This speeds up 3 times the execution in PHP 5.2.
* XML loader now returns valid JSON. There is no reference to loading ID in this format.
* New documentation: easy to understand tutorial ( ) and protocol specifications ( ).

Comment by Dmitry Koterov — August 23, 2007

Leave a comment

You must be logged in to post a comment.