我如何获得$ .getScript正常工作?
-
14-11-2019 - |
题
我可以看到jQuery的$ .getScript位会使它一旦工作,但这是我遇到问题的最后一点。我怀疑问题是通过我加载js文件的方式引起的。我如何实现这项工作?我的index.html实际上是index.php,身体标签之间很少。我正在使用jquery 1.7.1
<body id="btLive">
<script>
buildInterfaces();
</script>
</body>
.
buildinterfaces()驻留在名为layoutloader.js的文档中。在该文件中,我有以下内容:
$(document).ready(function() {
$('#hToggle').click(function() {
aaa = "Not working.";
$.getScript('test.js', function() {
alert(aaa);
});
toggleHoverPanel();
});
});
.
作为我的测试,test.js与layoutloader.js相同的文件夹,只包含以下内容:
aaa = "Successful Load."
.
当我点击按钮htoggle时,嘟嘟overpanel发生,我没有警报。如果我在aaa=“不工作”之后拨弄警报;我得到了我期望的警报,告诉我它不起作用。我有许多物品我需要用它,但对于我的生活,我无法让它工作。帮助?
解决方案
With high probability test.js file could not by found. Add this piece to your code and try again:
$(document).ajaxError(function(event, request, settings){
alert('error loading: ' + request.status);
});
不隶属于 StackOverflow