Ajax Request HTML
<script></script>及外部的js文件,都需要
var scriptStrs = response.match(/<[s]*?script[^>]*?>[sS]*?<[s]*?/[s]*?script[s]*?>/gi); if(scriptStrs) { // remove defer-scripts from HTML content for (var i = 0; i < scriptStrs.length; i++) { response = response.replace(scriptStrs[i], ""); } } screenLoader_this.deferredScriptsStrs = scriptStrs; screenLoader_this.htmlResponse = response;
截取并替换HTML中的<script>。
外部的js则需要另行加载。
JS APP ----------------------->JS/H5/CSS3(Client Side)=========>response方式:路径
----------------------->JSON/Text/XML(Server Side)======>response方式:Servlet
Andorid APP----------------->JSON/Image/XML(Server Side)=======>response方式:Servlet
Load JS-------->js的路径
dojo.xhrGet({ url: uri, sync: !opt.async, handleAs: "text", load: function(data, ioArgs) { // TODO }catch(e){ throw e; } }, error: function(error, ioargs) { // TODO } });
Load CSS------>CSS的路径
var css = document.createElement('link'); css.rel = 'stylesheet'; css.type = 'text/css'; css.href = cssUrl; document.body.appendChild(css);
Load JSP------->Servlet