Ajax object of prototype. js

Source: Internet
Author: User

I think the ajax objects in prototype. js will certainly attract a lot of people and a large number of encapsulated ajax logic classes will be of great help to our beginners who use ajax.
Here is an example of my use:
1. Ajax. Request
You can create it like this Copy codeThe Code is as follows: var url = 'HTTP: // yoursever/your/your ';
Var pars = 'id = XXX ';
Var myAjax = new Ajax. Request (
Url,
{Method: 'get', parameters: pars, onComplete: yourfunction}
);

Parameters indicates the parameters you want to pass, such as id = xxx.
XMLHttpRequest is divided into Loading, Loaded, Interactive, and Complete in the HTTP request.
Ajax. Request objects can call your custom methods at any stage, in the form of onxxxxxxx: yourfunction. For example, onComplete mentioned above is the most commonly used method.
Code actually used in the exampleCopy codeThe Code is as follows: function sends (id)
{
C = $ ('content ');
O = $ ('old-content ');
C. innerHTML = "<div id = 'loading'> loading... </div> ";
O. innerHTML = c. innerHTML;
C. style. display = 'none ';
O. style. display = 'block ';
Var myAjax = new Ajax. Request ('content _ '+ id + '.html', {method: 'get', onComplete: updates });
}
Function updates (response)
{
New Effect. Fade ($ ('old-content '));
New Effect. Appear ($ ('content '));
$ ('Content'). innerHTML = response. responseText;
}

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.