Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery在IE6中不工作_Javascript_Jquery - Fatal编程技术网

Javascript jquery在IE6中不工作

Javascript jquery在IE6中不工作,javascript,jquery,Javascript,Jquery,我在jquery中开发了一个下拉类别和子类别菜单。该脚本在Firefox、chrome上运行,但在IE6中不起作用。你能指导我解决这个问题吗 <script type="text/javascript"> $(document).ready(function() { $('#loader').hide(); $('#show_heading').hide(); $('#search_category_id').change(function() {

我在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>

$(文档).ready(函数(){
$(“#加载程序”).hide();
$(“#显示标题”).hide();
$('#搜索_类别_id')。更改(函数(){
$(“#显示子类别”).fadeOut();
$(“#加载程序”).show();
$.post(“get_chid_categories.php”,
{
父项_id:$('#搜索_类别_id').val(),
},
功能(响应){
setTimeout(“finishAjax('show_sub_categories','”+转义(response)+“)”,400);
}
);
返回false;
});
});
函数finishAjax(id,响应){
$(“#加载程序”).hide();
$(“#显示标题”).show();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
} 
函数警报\u id(){
如果($('#子#类别_id').val()='')
警报('请选择子类别');
其他的
警报($('#子#类别_id').val());
返回false;
}

您是否声明了文档类型

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

您可能有不正确的HTML。这可能是一个HTML问题


请提供您的HTML。

您是否声明了文档类型

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

您可能有不正确的HTML。这可能是一个HTML问题


请提供您的HTML。

正如其他人所说,您需要指定错误是什么以及发生在哪里(即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;
} 
$(文档).ready(函数(){
$(“#加载程序”).hide();
$(“#显示标题”).hide();
$('#搜索_类别_id')。更改(函数(){
$(“#显示子类别”).fadeOut();
$(“#加载程序”).show();
$.post(“get_chid_categories.php”,
{
父项_id:$('#搜索_类别_id').val(),
},
功能(响应){
setTimeout(“finishAjax('show_sub_categories'),”+
逃避(回应)+
"')",
400);
}
);
返回false;
});

}); // 正如其他人所说,您需要指定错误是什么以及发生在哪里(即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;
} 
$(文档).ready(函数(){
$(“#加载程序”).hide();
$(“#显示标题”).hide();
$('#搜索_类别_id')。更改(函数(){
$(“#显示子类别”).fadeOut();
$(“#加载程序”).show();
$.post(“get_chid_categories.php”,
{
父项_id:$('#搜索_类别_id').val(),
},
功能(响应){
setTimeout(“finishAjax('show_sub_categories'),”+
逃避(回应)+
"')",
400);
}
);
返回false;
});

}); // 移除了setTimeout中的escape | unescape和eval

<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>

$(文档).ready(函数(){
$(“#加载程序”).hide();
$(“#显示标题”).hide();
$('#搜索_类别_id')。更改(函数(){
$(“#显示子类别”).fadeOut();
$(“#加载程序”).show();
$.post(“get_chid_categories.php”,
{
父项_id:$('#搜索_类别_id').val(),
},
功能(响应){
//改变
var f=function(){finishAjax('show_sub_categories',response);};
设置超时(f,400);
}
);
返回false;
});
});
函数finishAjax(id,响应){
$(“#加载程序”).hide();
$(“#显示标题”).show();
//改变
$('#'+id).html(回应);
$('#'+id).fadeIn();
} 
函数警报\u id(){
如果($('#子#类别_id').val()='')
警报('请选择子类别');
其他的
警报($('#子#类别_id').val());
返回false;
}

删除了escape |在setTimeout中取消escape和eval

<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>

$(文档).ready(函数(){
$(“#加载程序”).hide();
$(“#显示标题”).hide();
$('#搜索_类别_id')。更改(函数(){
$(“#显示子类别”).fadeOut();
$(“#加载程序”).show();
$.post(“get_chid_categories.php”,
{
父项_id:$('#搜索_类别_id').val(),
},
功能(响应){
//改变
var f=function(){finishAjax('show_sub_categories',response);};
设置超时(f,400);
}
);
返回false;
});
});
函数finishAjax(id,响应){
$(“#加载程序”).hide();
$(“#显示标题”).show();
//改变
$('#'+id).html(回应);
$('#'+id).fadeIn();
} 
函数警报\u id(){
如果($('#子#类别_id').val()='')
警报('请选择子类别');
其他的
警报($('#子#类别_id').val());
返回false;
}

你能解释一下什么不起作用吗?很多东西在IE6中不起作用……你可以通过升级IE来修复:)@Mud Dib-问题不在于OP的浏览器,而在于用户。升级是他们的选择,他们会在自己的时间内完成。你能解释一下什么不起作用吗?很多东西在IE6中不起作用…你可以通过升级IE来解决:)@Mud Dib-问题不在于OP的浏览器,而在于用户。升级是他们的选择,他们将在自己的时间内完成。网络上提供的大多数文档中包含的DOCTYPE与浏览器处理DOCTYPE的方式没有任何相似之处。上述内容可能作为text/html使用,并被视为HTML4.01过渡版(或非过渡版)。您认为DOCTYPE会给这两种DOCTYPE带来什么问题?web上提供的大多数文档中包含的DOCTYPE与浏览器处理DOCTYPE的方式没有相似之处。上述内容可能作为text/html使用,并被视为HTML4.01过渡版(或非过渡版)。您认为DOCTYPE会对任一DOCTYPE造成什么问题?关于“这是额外的”:您没有正确地重新格式化代码。你的额外费用到此为止