[英]jquery not working in IE6
我在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;
}
您是否声明了doc-type?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
您可能有不正确的HTML。 这可能是HTML问题。
请提供您的HTML。
在setTimeout中删除了转义和评估。
<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) {
// CHANGED
var f=function(){finishAjax('show_sub_categories',response);};
setTimeout(f, 400);
}
);
return false;
});
});
function finishAjax(id, response){
$('#loader').hide();
$('#show_heading').show();
// CHANGED
$('#'+id).html(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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.