(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