开发者

jQuery functionality not working on Chrome and IE 8

I am a beginner in jQuery.I am working on fixing a bug that I see on my website. I have a ajax call that is executed if you check/uncheck the checkbox in the cart. So if I uncheck something in my cart it gets save automatically . This is working in FF but not in Chrome or IE . Any suggestions as to what could be开发者_JS百科 the problem ?

function toggleDisplay(id,boutiqueid){
  obj = $('#'+id);
  chk = obj.find('input[name='+id+']');
  if(chk.is(':checked')){
    $.ajax({
      url:'MyRecentPurchaseProcess.jsp?action=add&boutiqueId='+boutiqueid+'&shipment='‌​+id,
      success: function(data) {
        eval(data);
        if(outcome.result=='true'){
          obj = $('#'+id);
          obj.find('.blanket_fold').attr('class','blanket_unfold')
          obj.find('.prod').attr('class','prod_under');
        }
      }
    });
  } // inserted by editor
  else{
    $.ajax({
      url:'MyRecentPurchaseProcess.jsp?action=delete&boutiqueId='+boutiqueid+'&shipmen‌​t='+id,
      success: function(data) {
        eval(data);
        if(funcResult.result == 'true'){
          obj = $('#'+id);
          obj.find('.blanket_unfold').attr('class','blanket_fold')
          obj.find('.prod_under').attr('class','prod');
          chk = obj.find('input[name='+id+']');
          chk.attr('checked',false);
        }
      }
    });
  } // inserted by editor
} // inserted by editor


IE is strict regarding element ids, look for duplicate ids of the element. FF usually neglects them and works but IE don't.


Please include the code part where you call this function (setting up the event handler), it's hard to find the problem without that. You have some strange selectors but they might be correct, depending on your HTML.

Note that since jQuery 1.6, using prop() is recommended instead of attr() when editing properties like checked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜