Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading js dynamically not reflecting
    text
    copied!<p>I want to load js on the fly which is happening but the one more js file which is included in index is loading before (file i am loading dynamically) is there way to fix the order</p> <p>i am adding global.js dynamically and i want variable declared in global.js shoud be initialised before dynamicjs.DynamicJs is loaded</p> <p>------------- Index.html -------------</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;script src="resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-libs="sap.ui.commons" data-sap-ui-theme="sap_goldreflection" &gt; &lt;/script&gt; &lt;!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required --&gt; &lt;script src="js/dyn.js"&gt;&lt;/script&gt; &lt;script&gt;&lt;/script&gt; &lt;script&gt; sap.ui.localResources("dynamicjs"); var view = sap.ui.view({id:"idDynamicJs1", viewName:"dynamicjs.DynamicJs", type:sap.ui.core.mvc.ViewType.JS}); view.placeAt("content"); &lt;/script&gt; &lt;/head&gt; &lt;body class="sapUiBody" role="application"&gt; &lt;div id="content"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <hr> <pre><code>function loadScript(url){ var xhrObj = createXMLHTTPObject(); // open and send a synchronous request xhrObj.open('GET', url, false); xhrObj.send(''); var e = document.getElementsByTagName("script")[1]; var d = document.createElement('script'); d.src = url; d.type = 'text/javascript'; d.async = false; d.defer = false; e.parentNode.insertBefore(d,e); } function addScriptDynamically(){ loadScript('js/global.js'+'?scheme=12345'); } function createXMLHTTPObject(){ var xmlhttp=new XMLHttpRequest(); if( typeof xmlhttp == 'undefined' || xmlhttp == null ) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); return xmlhttp; } /*call function */ addScriptDynamically(); </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