Jquery ajax在IE中不能正常工作

时间:2010-09-22 13:56:17

标签: jquery internet-explorer-7

我们正在构建一个Web应用程序,它在'select'标签上使用jquery ajax和jsp。 Ajax请求适用于所有浏览器,当然,臭名昭着的IE家族除外。通常,如果我点击“选择”标签,它应该根据所选的选项动态填充其他“选择”标签。 但在IE中,此功能第一次起作用,然后第二次停止工作。然后当我第三次点击另一个'select'标签时,一切正常。 这是第二次让我担心。

这是jquery ajax代码,它适用于所有'select'标签的所有onchange事件:

function updateAvailableAttributes() {
var form = document.forms["orderDefinition"];
form.elements["formChangeRequest"].value = "true";
$.ajax({
  type: "POST",
  cache: false,
  dataType: "html",
  url: "ajax/possibleValues.html",
  data: $("form#orderDefinition").serialize(),
  success: function(response){
    $('#usercontent .sleeve .toprow').html(response);
        //alert("Ajax is working!");
    applyValidation();
    radioButtonHighlightSelection();
  },
  error: function(response, ioArgs, err) {
         if (response.status == 601) {
             sessionTimedOut();
         }
  }       
});

// Display a "please wait" message
$("#waitingMsgOverlay, #waitingMsgBox, #waitingMsg, #waitingMsgParag").ajaxStart(function(e){
      var map = document.getElementById("OrderMap");
      map.disableApplication();
      $(this).show();
  }).ajaxStop(function(e){
      var map = document.getElementById("OrderMap");
      map.enableApplication();
      $(this).hide();
      $("#toolpanel").height($("#orderMap").height());
});
}

请告诉我这件事,这很烦人。

这是'radiaButtonHighlightSelection()'代码:

function radioButtonHighlightSelection()
{   
var radioBtnCollection = $("#orderDefinition input:radio");
var radioBtnCheckedCollection = $("#orderDefinition input:radio:checked");
var checkBoxCollection = $(".fixedPricedAreasHolder input:checkbox");
var checkBoxCheckedCollection = $(".fixedPricedAreasHolder input:checkbox:checked");

radioBtnCollection.each(function(i, elemRd)
{
    if(elemRd.checked)
    {
        $(this).parent().addClass("selectedRadioBg");
        $(this).parent().next(".fixedPricedAreasHolder").addClass("selectedCheckboxBg");
    }
    else
    {
        $(this).parent().removeClass("selectedRadioBg");
    }

    checkBoxCollection.each(function(i, cb)
    {
        if(cb.checked)
        {   
            if($("#orderDefinition input:radio:eq(0)")[0].checked){
                $("#orderDefinition input:radio:eq(0)").removeAttr("checked");
                $(this).parent().parent().prev().find("input:radio").attr({"checked": "checked"});
                $(elemRd).parent().removeClass("selectedRadioBg");

                $(this).parent().parent().prev().addClass("selectedRadioBg");
                $(this).parent().parent().addClass("selectedCheckboxBg");
            }
            else if(cb.checked ==  false){
                $("#orderDefinition input:radio:eq(0)").attr({checked: "checked"});
                $("#orderDefinition input:radio:eq(1)").attr({checked: "checked"});
            }
        }
    });

});
}

提前致谢。

1 个答案:

答案 0 :(得分:1)

@Shaoz - 您需要显示您打开单选按钮的方式。也许展示radioButtonHighlightSelection()功能。由于事件执行顺序,IE在正确执行jQuery事件时遇到问题。我想您可能希望在执行blur事件后执行click事件。

您可能想查看我的question on checkboxes

相关问题