Javascript 如何从从<;加载的脚本请求中获取jqXHR对象;脚本>;标记内部<;头>;
当加载脚本时,jQuery的getScript()返回jqXHR对象。 当从放置在head标记中的script标记加载脚本时,是否有方法获取jqXHR对象Javascript 如何从从<;加载的脚本请求中获取jqXHR对象;脚本>;标记内部<;头>;,javascript,jquery,html,xmlhttprequest,Javascript,Jquery,Html,Xmlhttprequest,当加载脚本时,jQuery的getScript()返回jqXHR对象。 当从放置在head标记中的script标记加载脚本时,是否有方法获取jqXHR对象 function makeScript(url){ script = document.createElement("script"); script.src = url; //when this line is executed the script will be loaded by the browser
function makeScript(url){
script = document.createElement("script");
script.src = url;
//when this line is executed the script will be loaded by the browser
//how to get the jqxhr object
document.head.appendChild(script);
}
没有,因为没有。浏览器以本机方式处理所有内容 否。XHR不会与附加的脚本元素一起保存,被请求的脚本也不知道正在进行的请求。请使用jquerys@BenG+1为我指出正确的方向。我替换了
document.head.appendChild(脚本)代码>到链接中提到的$.get。发现另一个问题,无法调试脚本,因为加载了$.get的脚本未显示在CDT源选项卡中