parser

Class for Working with JsHttpRequest

Author: Misha v.3 [March 23, 2006]
Version: 1.12
Tags: JS

I decided to play around with Ajax...

There was absolutely no desire to reinvent the wheel, and remembering that JsHttpRequest.js from dklab.ru had been chewed over on the forum more than once, I naively figured that finding, hooking up, and using an existing solution would be the fastest option.

Yeah... right. Siao liao. For some reason, everyone who'd tried to cross it with Parser seemed to have done it half-heartedly and never got as far as "downloaded it, hooked it up, it works," and never submitted code for the "Examples" section (well... or maybe they did get there but never showed it to anyone, or maybe I just didn't search well enough). Anyway, I had to fill that gap myself, hopefully I managed to do it at least a little better.

To actually try the class out, download it, unpack the archive wherever's convenient, and open the _test_all.html file over http from a browser. When testing, don't forget to check Cyrillic letters and symbols. You won't find anything new on the frontend (it's all exactly as the doctor, meaning Dmitry Koterov, prescribed), but the class can substantially simplify writing the backend (see the _js_http_request_load.html file).

A simple chat using this class was also written, which can also be considered a small test of it.

Related links:

  • http://dklab.ru/lib/JsHttpRequest/ — an article about this technology on dklab.ru (version 5 of the JsHttpRequest.js file is included in the archive);
  • http://www.ipo-design.ru/developments/lab/httprequest/ — a set of methods intended for use with the old JSHttpRequest.js class, it doesn't work with Cyrillic letters, and the archive's code has some outright logical errors (sorry, author, but it's true);
  • http://www.parser.ru/forum/?id=41408 — a set of methods by Sergey M., which only needed the smallest amount of filing down (the archive includes a test file _js_http_request_test.html, which shows the differences between the original methods and the updated ones moved into the class);
  • http://www.parser.ru/forum/?id=60053 — changes by Sergey M. for working with version 5 of JsHttpRequest.js, which he implemented in the class in addition to MadCow's changes;
  • http://www.spearance.ru/ — Eugene let me swipe from him (more precisely, he gave it to me himself) the table for decoding %u0380 & Co, which also fit in almost without any filing down (I, and Sergey M., already mentioned here more than once, only had to add some characters).

One final note: if you don't understand anything about javascript — forget about Ajax, since the proposed class only helps simplify writing the backend (the server-side part that receives Ajax requests, decodes them, performs some actions, and sends the results back), while writing the frontend (javascript code that, based on the data received from the backend, dynamically modifies the page) is something you'll still have to do yourself.

Download:

JSHttpRequest.zip (11.12.2007  13.2 KB)
Archive of the class with the developers' js and an example.

JSHttpRequest.3.x.zip (21.04.2006  9 KB)
Archive of the old version of the class (3.x), with the developers' js and an example.