javascript - SCRIPT src not loaded after append in to HTML using jQuery -


i developing application required load new html , append current page html.

now, loaded new html using jquery ajax in new loaded html have <script> display audio play. issue when script load script tag loaded html not display not loaded.

i used:

<script src="link of js file create audio" type="text/javascript"></script> 

above code not display / not loaded after append.

i append like:

var html = '<div> <h1>header</h1> <div>contain area</div>             <script src="link of js file create audio" type="text/javascript"></script></div>' $("#container").append(html); 

but not working. 1 have idea in it.

thanks

you can use jquery getscript();

$.getscript( "url/for/script.js" )     .done(function( script, textstatus ) {         console.log( 'script loaded' );      })     .fail(function( jqxhr, settings, exception ) {         console.log( 'script not loaded' );      }); 

this append javascript file in script tags.

read more here.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -