Someone in the group today asked how to load js with ajax, and I haven't used it yet. I asked why I used ajax to load JS, and I learned that the js file is very large, and it needs to be loaded when the user clicks a certain button, and it usually does not need to be loaded. In this way, loading js with ajax seems necessary in some cases.
So I entered ajax into Google to load js, and saw that the first one turned out to be an article on my website, and the content of the article was loaded js using Google API, which may be that the title of my article is not very standardized. After checking the jQuery documentation, there is a ready-made method to load the js file, how to use it as follows:
For example, in jsname.js file there is a statement:
In this way, first output "ajax load js", wait for the file to be loaded jsname.js complete, execute the callback method, and output "ajax load js complete the method to be executed". This is considered to be the loading of ajax js. |