Home > Web Front-end > JS Tutorial > body text

Detailed explanation of the difference between jQuery.load() and Jsp include

小云云
Release: 2018-01-17 16:39:23
Original
2152 people have browsed it

This article mainly brings you a detailed discussion of the difference between jQuery.load() and Jsp include. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look, I hope it can help everyone.

1. jqueryObj.load()

The load() method obtains server-side data through ajax and places the returned data under the jqueryObj object.

load(url,data,function(response,status,xhr)
Copy after login
Parameters Description
url Specifies where to send the request URL.
data Optional. Specifies the data to be sent to the server with the request.
function(response,status,xhr)

Optional. Specifies a function to run when the request completes.

Extra parameters:

  • response - Contains the result data from the request

  • status - Contains the status of the request (" success", "notmodified", "error", "timeout" or "parsererror")

  • xhr - Contains the XMLHttpRequest object

We can also get only part of the returned data, for example:

$("#a").load("b.html","#c") : Get part of the content with id c in b.html and fill it under the element with id a.

Note: If the content loaded by load contains js, it will be compiled once when the js is filled into the specified element.

2. <%@include file="Page path"%>

This is a jsp command operation, which embeds the content of the specified path into the location of the command. This is a static loading method.

Loading timing: Before the container converts the jsp into a servlet file, it is integrated with the original page code and then parsed. (Translation stage)

Note: Because two documents are combined into one and then parsed, the same header may exist, which may cause parsing errors, so try to remove the header of the imported file so that the original The header content of the page.

3.

This is a behavioral operation. When requesting a page, the page with the specified path will be translated. and execute it, and place the execution result where the code is located.

Loading timing: The imported page and the original interface will be translated and executed separately when the page is requested. It will be translated into 2 servlet files. They are relatively independent, and the results will be displayed together only when displayed. (Executed during request processing)

Note: Because the two pages are relatively independent, they need to be processed independently. There may be garbled characters caused by inconsistent encoding sets of the two pages.

Related recommendations:

Usage of JavaScript refresh page location.reload()

ajax application in jquery Detailed explanation of examples of load() function

The difference between jQuery’s HTML() and Load()

The above is the detailed content of Detailed explanation of the difference between jQuery.load() and Jsp include. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!