gpt4 book ai didi

javascript - Internet Explorer 不解析 javascript 方法

转载 作者:行者123 更新时间:2023-11-28 04:39:42 24 4
gpt4 key购买 nike

我有一个带有过滤功能的网页。过滤使用一个 javascript 文件,该文件在 header 中链接如下:

<script type="text/javascript" src="https://www.werkenbijtauw.nl/static/default/script/autotag.js"></script>

文件的内容定义自动标记方法:

var autotag = {
filter: function(container, resetPage = true){
if(resetPage)
$('#filter-page').val('1')

var form = $('#'+container);
var action = form.attr('action');
var method = form.attr('method');
var data = form.serialize()+'&method=ajax';

$.ajax({
url: action,
data: data,
method:method,
success: function(response, status, xhr){
history.pushState(null,null, window.location.pathname+'?'+form.serialize());
$('#'+container).html(response);
}
});
}
};

在我的 html 正文中,我有以下 html:

<input type="checkbox" id="Bodem" name="filters['function'][]" value="Bodem" onchange="autotag.filter('vacancies-filters');" />

在 Chrome 和 Firefox 中,这不会导致任何问题。另一方面,IE 会抛出一个未定义自动标记的错误。为什么 IE 会认为 autotag 变量未定义,有什么想法吗?

最佳答案

<script type="text/javascript" defer="defer" src="https://www.werkenbijtauw.nl/static/default/script/autotag.js"></script>

关于javascript - Internet Explorer 不解析 javascript 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43886215/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com