The loading process of JSP pages

Source: Internet
Author: User

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.

JS code is part of the HTML code, so the page loads when it is loaded from top to 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

Because of the asynchronous loading of Ajax, it is possible that the order in which statements are executed is not executed in the order in which they appear. Here's an example of the problem I encountered when I did the task:

In the initial loading of the page needs to send a request to the JSP to obtain the data required by the page, in the Ajax success function, the operation of the data takes too long, it will lead to the Ajax function outside the confirm and loadtree than the statement after the data operation is executed first. Finally, the time to use data in Loadtree is empty, when the global variable opentab_id is empty.

2.3 Control JS Execution sequence

You can use settimeout (function (), time), and the function to delay loading.

reprint to:http://www.jb51.net/article/45374.htm

The loading process of JSP pages

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.