JavaScript Ajax Learning

Source: Internet
Author: User
Tags add time

(1)
All files must be encoded in a uniform
(2)
Caching: Caching based on URLs
Block cache:
Add Time//new Date () after the file name. GetTime ()
(3)
Ajax reads all the strings.
Workaround:
eval (str);//Parse the string into a JS code that can be executed
(4)
Get: Via URL
The length of the URL is limited, the capacity is small, the security is poor, there is cache
Used to get data
? name = value & First name = value
Post: Not through the URL, the capacity of 2G, better security, no cache
Passing Data
(5)
1. Creating an Ajax Object
2. Connect to the server
3. Sending the request
4. Accept the return value
(6)
Variable not defined--error
Undefined attribute--undefined
So with:
Window. XMLHttpRequest
(7)
Sync: One Piece to
Async: Multiple things together
(8)
oajax.readystate//Monitoring Server and browser, to which step
0: Create Ajax object, but do not call the Open method
1: The Send () method is called and the request is being sent
2:send method completed, received all response content
3: Parsing response content
4: Finish parsing, can be called again by client
HTTP status code:
Oajax.status = = 200//success
(9)
Cases:
if (window. XMLHttpRequest) {
var oajax = new XMLHttpRequest ();
}else{
var oajax = new ActiveXObject ("Microsoft.XMLHTTP");
}
Oajax.open (' GET ', ' a.txt ', true);
Oajax.send ();
Oajax.onreadystatechange = function () {
if (oajax.readystate==4) {
if (oajax.status==200) {
oajax.responsetext;//Read back the content
}else{
Oajax.status
}
}
};

JavaScript Ajax Learning

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.