Ajax General class: Ajaxrequest v0.3

Source: Internet
Author: User
Tags empty
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







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.