Loading JavaScript Into Div Dynamically

前端 未结 6 1158
难免孤独
难免孤独 2021-01-22 15:32

I need to load JavaScript code (which I don\'t have control over) from a URL into a div. The JavaScript code is a bunch of document.write() statements. Once the document.write()

6条回答
  •  孤城傲影
    2021-01-22 16:19

    You should see the jQuery.getScript() function.

    Here is from the doc's example:

    $.getScript('ajax/test.js', function(data, textStatus){
       console.log(data); //data returned
       console.log(textStatus); //success
       console.log('Load was performed.');
    });
    

提交回复
热议问题