AJAX request class

Source: Internet
Author: User
After I added the refresh search and instant verification detection to my blog, I read the code and felt too much trouble. I encapsulated the XMLHttpRequest request into a class, which is much more convenient to use, there is no need to remember so much code, what is the creation of the XMLHttpRequest object?

AddNo refreshing searchAfter the real-time verification and detection, I read the code again and felt too much trouble. I encapsulated the XMLHttpRequest request into a class, which is much more convenient to use and does not need to remember so much code, what does it mean to create an XMLHttpRequest object? this part of code is highly reusable ~ It has been packaged and downloaded at the end of the log.

What are the consequences?Search logs in the left sidebarThere is a refreshing search, or there is instant detection in the registration code in the browsing log or message book. if you do not enter the verification code or enter the wrong verification code, the input box will become red.

Class name: AJAXRequest

Creation method: Var ajaxobj = new AJAXRequest; if creation fails, false is returned.

Attribute:

  • Method-request method, string, POST, or GET. the default value is POST.
  • Url-request URL, string, empty by default
  • Async-asynchronous or not. true indicates asynchronous, and false indicates synchronous. the default value is true.
  • Content-requested content. if this attribute is required for the request method of POST, the default value is null.
  • Callback-callback function, that is, the function called when the response content is returned. the default value is direct return.
  • The function has an XMLHttpRequest object, that is, the callback function must be defined as follows: function mycallback (xmlobj)

Method: Send-send request, no parameter

Example:

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.