A JS file A is initially loaded in the original html file, which contains a large number of functions.
When an external JS file B is loaded after executing an event, JS file B calls the function in file A. Logically speaking, JS file A has been loaded successfully after the page is loaded, and the imported JS file B should You can use it directly. Why can't you call the function in file A? An error will be reported. . .
a.js content:
Function 1,
Function 2,
$('#btn3').unbind('click'). click(function(e){
e.stopPropagation();
$.getScript('b.js');
})
b.js content:
Function 1();
After b.js is loaded successfully, no other elements can be added except calling functions. No problem. What is the reason?
PHP中文网2017-09-04 09:07:37
You can take a screenshot of the error, it may be a function scope issue.