JsHttpRequest
From Wikipedia, the free encyclopedia
| This article may require cleanup to meet Wikipedia's quality standards. Please improve this article if you can. (August 2007) |
| This article or section needs sources or references that appear in reliable, third-party publications. Primary sources and sources affiliated with the subject of the article are generally not sufficient for a Wikipedia article. Please include more appropriate citations from reliable sources, or discuss the issue on the talk page. This article has been tagged since August 2007. |
JsHttpRequest is an easy-to-use cross-browser AJAX library with AJAX file uploading support and many other features. JsHttpRequest first appeared as cross-browser analogue of XMLHttpRequest, and then became a very useful instrument to create dynamic web pages. It uses JavaScript (ActiveX, DOM, XMLHttpRequest if available) in frontend and PHP in backend.
Here is a short list of library's most interesting features and benefits.
- Excellent cross-browser compatibility (e.g. works with IE 5.0 with disabled ActiveX).
- Support and "transparent" work with any character encoding (including any national).
- AJAX file uploads from a user browser to the server without a page reloading.
- Full support of PHP debug features and coding traditions.
- Multi-dimensional data structures exchange (associative arrays).
- Automatic choice of the best AJAX realization (XMLHttpRequest, <SCRIPT>, <IFRAME>).
- XMLHttpRequest-compatible interface is available.
The main idea of JsHttpRequest is to be simple and transparent for all programmers and habitual programming techniques:
- PHP notices and errors (including fatal) are not break the script execution;
- there is no need of any framework (e.g. classes) to build a server part;
- PHP arrays are converted to JS objects and back fully transparently;
- forget about national encodings problems (e.g. works with windows-1251 on PHP part).
Examples:
// JavaScript code:
JsHttpRequest.query(
'your_ajax_script.php',
{
first: 'Dmitry',
last: 'Koterov',
file: document.getElementById("my_upload_file")
},
function(result, debugMessages) {
document.getElementById("result").innerHTML = result.text;
if (debugMessages) alert(debugMessages);
}
);
// PHP code:
require_once "lib/JsHttpRequest.php";
$JsHttpRequest =& new JsHttpRequest("windows-1251");
$_RESULT['text'] = "Hello, {$_REQUEST['first']} {$_REQUEST['last']}!";
echo "Any debug message or even a fatal PHP error";
Library's homepage:
- http://en.dklab.ru/lib/JsHttpRequest/ (English)
- http://dklab.ru/lib/JsHttpRequest/ (Russian)
Author:
- Dmitry Koterov, http://koterov.ru

