簡體   English   中英

jQuery的無法在IE6

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM