Home  >  Q&A  >  body text

js file dynamic loading calling problem

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?

按键盘手指磨破皮按键盘手指磨破皮2604 days ago1351

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-09-04 09:07:37

    You can take a screenshot of the error, it may be a function scope issue.

    reply
    0
  • 按键盘手指磨破皮

    The error message is that this function does not exist adeu is not defined adeu is a function

    按键盘手指磨破皮 · 2017-09-04 11:33:21
  • Cancelreply