0

I am developing application where required to load new HTML and append into current page HTML.

Now, I loaded new HTML using jQuery ajax but in new loaded HTML have <script> which display audio to play. But my issue is when script load then script tag from loaded HTML not display even not loaded.

I used:

<script src="Link of JS file which 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 which create audio" type="text/javascript"></script></div>'
$("#container").append(html);

But not working. Any one have a idea in it.

Thanks

1 Answer 1

1

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 will append the JavaScript file in script tags.

Read more here.

Sign up to request clarification or add additional context in comments.

1 Comment

Some mis-understanding here. Can you please check updated question now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.