Jquery page Initialization is commonly used in three ways, and Jquery sends ajax requests, jqueryajax
First
$ (Document). ready (function (){
// Document readiness event
});
The second is the first simple method, which is equivalent to the first method.
$ (Function (){
// Document loading event, which is executed after the entire document is loaded. You only need to load all the DOM structures and execute the js effect before the browser puts all the HTML into the DOM tree. Including before loading external images and resources.
});
Third
JQuery (function ($ ){
});
Window. onload = function (){
// Onload event is the code onload event in js that occurs when the HTML is read, the DOM tree is generated in the memory, and the onload event occurs only after the three things of page rendering are completed. After all the documents on the entire page are loaded, execute. Unfortunately, this method not only requires that the DOM tree of the page be fully loaded, but also requires that all external images and resources be fully loaded. Unfortunately, if external resources and sample files take a long time to load, this js effect will make the user feel ineffective.
}
Simplified syntax window. onload is not simplified syntax $ (document). ready (function () {}) can be abbreviated to $ (function (){});
The $ symbol is a commonly used "selector" in the JS library. For example, $ in JQuery is the abbreviation function of Selector. For example, $ (this) is the meaning of "select now.
$. Ajax ({
Url: "request address ",
Type: "request method ",
Data: "Request Parameters ",
DataType: "server return data type ",
Success: "The callback function corresponding to normal server processing ",
Error: "callback function corresponding to server error"
});
The Code var url =$ ("# id") is displayed today "). attr ("menu-url"); I always thought it was adding attributes to the node. I haven't figured it out for a long time. It turns out to be an incorrect understanding. If two parameters are passed in attr, the attribute is added to the node. If there is only one parameter, the node content is obtained. Or I didn't understand it correctly at the beginning. Do not take it for granted.