【发布时间】:2013-04-03 23:14:49
【问题描述】:
当我得到一个包含<script src="some-file.js"></script> 的网址时,如下例所示:
<html>
<script>
$(document).ready(function(){
$.get('/some-url', function(r) {
$('#html-container').html(r); // Contains: <script src="some-file.js"></script>
});
});
</script>
<body>
<div id="html-container"></div>
</body>
这是之前在 some-file.js 自动加载中所说的结果,因为 /some-url 的结果比 jQuery 会将 ?_={random number} 添加到查询字符串中。
导致请求:GET some-file.js?_=1365695139815
如何从 html() 解析自动加载中禁用此随机请求附加?
@edit
由于我无法发出请求,那是因为它们是通过 html 解析执行的,在 Brian 的回答下,我找到了这个简单的解决方案:
$.ajaxSetup({
// Enable caching of AJAX responses
cache: true
});
【问题讨论】:
标签: jquery html-parsing autoloader