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: