Introduction to loading sequence for code execution in JSP pages

Source: Internet
Author: User
Tags function definition

This article is mainly on the JSP page in the code to carry out the loading sequence of detailed introduction, the need for friends can come to the reference, I hope to help you

1. Java is the code that runs on the server side, and the JSP runs in the server's servlet, while JavaScript and HTML are code that runs on the browser side.   So the load execution order is JAVA>JSP>JS. 2. JS in the JSP in the loading order page of the JS code on the part of the HTML code, so the page load is loaded from the top. So the order of JS loading is the order of <script> label appearing in the page.   <script> tags inside or the introduction of the external JS file is the order of execution of its statements appear in the order in which the process of JS execution is also part of the page load. 2.1 Global variables and functions defined in the JS script can be invoked in a later script. The call to the variable must be previously declared, otherwise the value returned by the variable is undefined.   In the same script, the function definition can appear after the function's call, and if the function's definition and invocation are 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, the execution order of the statements is not performed in the order in which the statements appear. Here's what I do when I do a task: When the page is initially loaded, you need 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, Will cause the confirm and loadtree outside the AJAX function to be executed first than the statements following the data operation.   The final use of data in the Loadtree is worth the time, when the global variable opentab_id is empty. 2.3 Control JS Execution order can use settimeout (function (), time), so that function delay load.
Related Article

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.