Ajax|request
class name :ajaxrequest
version : 0.3
Date : 2006-12-18
Introduction : Ajaxrequest is a convenient AJAX development of the General class, compatible with Firefox, IE, Opera, Safari, you can easily do some of the necessary Ajax operations, so as to simplify the development steps, reduce the number of repetitive code writing.
Demo Address:http://www.xujiwei.cn/works/ajaxrequest/
Instructions for use:
To create an object :
var ajax=new ajaxrequest ([Url],[callback],[content],[method],[async]);
Returns False if the creation fails
Properties :
URL-Request URL, string, default is NULL
Callback-callback function, that is, the function called when the response content is returned, the default is direct return, and the callback function has a parameter of XMLHttpRequest object, that is, when defining a callback function: function Mycallback (xmlobj)
Content-the contents of the request, if this attribute is set by the request method for post, the default is an empty string
Methods-Request method, String, post or get, default to post
Async-Asynchronous, true to asynchronous, false to synchronous, default to True
Method :
function send ([Url],[callback],[content],[method],[async])
To send a request, the optional argument list is empty to use the object property
function get ([Url],[callback])
Using the Get method to request a URL, the optional parameter uses the object property by default
function post (Form_obj,[callback],[url],[method])
Sends a form to the specified url,form_obj for the specified Form object, and the optional argument is empty when the object property is used
Example :
1. Use the Get method to obtain the contents of the specified URL
function Test1 () {
var ajax=new ajaxrequest;
Ajax.get (
"Test.asp",
function (obj) {document.getElementById ("Test1"). Value=obj.responsetext;}
);
}
2. Send the specified form using the Post method
function Test2 () {
var ajax=new ajaxrequest;
Ajax.post (
document.getElementById ("TEST2C"),
function (obj) {document.getElementById ("test2r"). Innerhtml=obj.responsetext;}
);
}
Click to download Ajaxrequest v0.3