This article mainly records all js failures caused by repeated jQuery loading in the project, and analyzes them step by step to get the complete process of the final solution, which is mainly recorded, remind yourself not to make the same mistake in the future. Recently, when I was working on a project, I encountered a problem:
The parent page introduces the child page and the Child page introduces the jQuery. js file. The parent page JS depends on jQuery. js. The problem is that the JS object is always prompted to be invalid. I guess the loading sequence of jQuery is not the earliest.
Parent page:
Subpage:
From this point of view, jQuery. js is the earliest, but why are other js prompts that the attribute is invalid.
Later I used the F12 tool of IE11 to check the JS loading sequence. I found that jQuery was the first to load, but after loading the page, a request suddenly loaded jQuery again.
The reason is the following code:
The Code is as follows:
$ (Function (){
$ ("# Zjyw_table_1"). load ("xxx. jsp ");
}
JQuery. js is loaded in xxx. jsp. It is normal to comment this sentence.
This problem has been quite depressing for a long time. Record it to help others.
After finding the solution, the solution is very simple. Here we will share with you the idea of querying the problem. If you have the same problem, you can refer to it.