Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to extract the code blocks between multiple script tags with JavaScript?
    text
    copied!<p>I have the following <strong>function</strong> which pulls in a <strong>Javascript block</strong> via AJAX from a URI and <strong>executes</strong> it:</p> <pre><code>function loadViewViaAjax(url, callbackOnSuccess) { Ext.Ajax.request({ url: url, success: function(objServerResponse) { var responseText = objServerResponse.responseText; var scripts, scriptsFinder=/&lt;script[^&gt;]*&gt;([\s\S]+)&lt;\/script&gt;/gi; while(scripts=scriptsFinder.exec(responseText)) { eval.call(window,scripts[1]); } if(typeof callbackOnSuccess != 'undefined') { callbackOnSuccess.call(); } } }); } </code></pre> <p>For example, it pulls in this text, and executes <strong>eveything between the SCRIPT tags</strong>:</p> <pre><code>&lt;script type="text/javascript"&gt; clearExtjsComponent(targetRegion); var start_info_panel = new Ext.Panel({ padding: 10, style: "margin: 10px", width: 300, html: '&lt;h1&gt;Html Item 1&lt;/h1&gt;' }); replaceComponentContent(targetRegion, start_info_panel); &lt;/script&gt; </code></pre> <p>How can I change the loadViewViaAjax function so that it executes <strong>everything between multiple script tags</strong>?, e.g.:</p> <pre><code>&lt;script type="text/javascript"&gt; clearExtjsComponent(targetRegion); var start_info_panel = new Ext.Panel({ padding: 10, style: "margin: 10px", width: 300, html: '&lt;h1&gt;Html Item 1&lt;/h1&gt;' }); replaceComponentContent(targetRegion, start_info_panel); &lt;/script&gt; &lt;script type="text/javascript"&gt; clearExtjsComponent(targetRegion_help); var help_panel = new Ext.Panel({ padding: 10, style: "margin: 10px", width: 300, html: '&lt;p&gt;This is the help text.&lt;/p&gt;' }); replaceComponentContent(targetRegion_help, help_panel); &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload