View a printer-optimized version of this page

AJAX/JSHttpRequest

Introduction

JSHttpRequest.js is a simple library that helps to add AJAX functionality to Web applications written on PHP or other server-side scripting language.

Released under GNU/LGPL license.

Copyright(c) 2007 Vagharshak Tozalakyan

Download

JSHttpRequest.zip (14 Kb)

Functions

JSR_createRequestObj()
Returnes XMLHttpRequest object or null if failed.

JSR_sendRequest(requestObj, method, url, callback[, formObj])
Sends asynchronous request to the server.
requestObj - Valid XMLHttpRequest object created by JSR_createRequestObj() function.
method - Type of request method - 'GET' or 'POST'.
url - URL to which the request is addressed.
callback - Client-side function that will receive the response and update page content.
formObj - Form object that will be submitted by POST method.

JSR_getResponse(requestObj, responseType)
Retrieves the response if ready. This function should be called inside the body of callback passed to JSR_sendRequest() function. It checks the status of request object and returns the response or false if failed.
requestObj - Valid XMLHttpRequest object created by JSR_createRequestObj() function.
responseType - Type of response - 'text' or 'xml'.

Examples

GET method requests
POST method requests