Introduction to code execution loading order in JSP pages

Source: Internet
Author: User

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.

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.