1. Usage
jquery’s load function is a call that requests another file and loads it into the current DOM. The full format of the load method is: load(url, [data], [callback] ) (note that if there are no parameters, it is a GET request, and if there are parameters, it is a POST method).
* url: refers to the address of the file to be imported.
* data: optional parameters; because Load can not only import static html files, but also dynamic scripts, such as PHP files, so when we want to import dynamic files, we can import The passed parameters are placed here.
* callback: optional parameter; refers to another function that is executed after calling the load method and getting a response from the server.
Caching speeds up page loading to a certain extent, but it often brings us trouble. In my previous article, I briefly introduced the use of the Load method in jQuery. In actual application, we may encounter browser cache problems. For example, I encountered this problem in IE7.
jQuery Load sample code:
1. Change the file name, such as changing labels.html to labels_new.html, but this is a no-brainer and generally no one does this.
2. Add a specific time after labels.html, such as labels.html?20081116. In actual work, after I update the css/javascript file, I always use this method to prevent the file from being cached.
3. Add the following statement at the top of the labels.html file:
4. The load function can not only call HTML, but also call script, such as labels.php. You can use the header function in the php file: