gpt4 book ai didi

javascript - jquery 在 IE6 中不工作

转载 作者:行者123 更新时间:2023-11-30 09:03:17 24 4
gpt4 key购买 nike

我在 jquery 中开发了一个下拉类别和子类别菜单。该脚本在 Firefox、chrome 中有效,但在 IE6 中无效。你能指导我解决这个问题吗

<script type="text/javascript">
$(document).ready(function() {
$('#loader').hide();
$('#show_heading').hide();
$('#search_category_id').change(function() {
$('#show_sub_categories').fadeOut();
$('#loader').show();
$.post("get_chid_categories.php",
{
parent_id: $('#search_category_id').val(),
},
function(response) {
setTimeout("finishAjax('show_sub_categories', '"+escape(response)+"')", 400);
}
);
return false;
});
});

function finishAjax(id, response){
$('#loader').hide();
$('#show_heading').show();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}

function alert_id() {
if($('#sub_category_id').val() == '')
alert('Please select a sub category.');
else
alert($('#sub_category_id').val());
return false;
}
</script>

最佳答案

正如其他人所说,您需要指定错误是什么以及发生的位置(即 IE 给您的错误消息)。

如果您格式化代码以使其更具可读性,我想您会发现语法错误:

$(document).ready(function() {
$('#loader').hide();
$('#show_heading').hide();
$('#search_category_id').change(function(){
$('#show_sub_categories').fadeOut();
$('#loader').show();

$.post("get_chid_categories.php",
{
parent_id: $('#search_category_id').val(),
},
function(response){
setTimeout("finishAjax('show_sub_categories', '" +
escape(response) +
"')",
400);
}
);
return false;
});
}); // <-- that is extra

function finishAjax(id, response) {
$('#loader').hide();
$('#show_heading').show();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}

function alert_id() {
if ($('#sub_category_id').val() == '') {
alert('Please select a sub category.');

} else {
alert($('#sub_category_id').val());
}
return false;
}

关于javascript - jquery 在 IE6 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7328791/

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