Original source: http://www.3lian.com/edu/2014/01-10/123053.html
This article is mainly on the JSP page code execution loading sequence is described in detail, the need for friends can come to the reference, I hope to be helpful to everyone
1. Java is code that runs on the server side, and JSP runs in the server's servlet, and JavaScript and HTML are code that runs on the browser side. So the order of loading execution is java>jsp>js. 2. JS in the JSP loading order page JS code when the HTML code part, so the page load is loaded by the top and bottom. So the order of JS loading is the order in which the <script> tags appear in the page. The order in which the external JS files are executed in the <script> tag is the order in which the statements appear, and the process of JS execution is also part of the page loading. 2.1 the global variables and functions defined in the JS script can be called in subsequent scripts. The call to the variable must have been declared previously, otherwise the value returned by the variable is undefined. In the same script, the function definition can appear after the call of the function, and if the function is defined and called in two script segments, the function call will report the function undefined error before the function definition. Asynchronous loading of Ajax in 2.2 JS due to the asynchronous loading of Ajax, the execution order of statements is not executed in the order in which they appear. The following is an example of a problem that I encountered when I was doing my task: when the page is initially loaded, it needs to send a request to the JSP to get the data needed for the page, and in the Ajax success function, the operation of data takes too long. Causes the confirm and loadtree outside the AJAX function to be executed first than the statements following the data operation. Finally, the time to use data in Loadtree is empty, when the global variable opentab_id is empty. 2.3 control JS Execution sequence can use settimeout (function (), time), and enable function delay loading.