2011-06-20 48 views
1

我是jQuery的初學者,我正致力於修復我在我的網站上看到的錯誤。如果您選中/取消選中購物車中的複選框,我會執行ajax調用。 所以,如果我取消選中我的購物車中的東西,它會自動保存。這在FF中工作,但不在Chrome或IE中。有什麼建議可能是什麼問題?jQuery的功能不適用於Chrome和IE 8

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

你能發佈你的代碼嗎?如果您展示迄今爲止所獲得的成果,那麼您將有更好的機會獲得解決方案。 – Town

+0

請向我們顯示您的代碼。沒有代碼,我唯一的猜測是你的事件監聽器設置是錯誤的(onchange/onchecked/onclick?) –

+0

function toggleDisplay(id,boutiqueid){ \t \t \t obj = $('#'+ id); \t \t \t chk = obj.find('input [name ='+ id +']'); \t \t \t如果(chk.is( ':檢查')){ \t \t \t \t $阿賈克斯({ \t \t網址: '?MyRecentPurchaseProcess.jsp行動=添加&boutiqueId =' + boutiqueid + '&出貨=' + ID , \t \t \t成功:功能(數據){ \t \t \t \t \t \t \t的eval(數據); \t \t \t \t \t \t \t如果(outcome.result == '真'){ \t \t \t \t \t \t \t \t OBJ = $( '#' + ID); \t \t \t \t \t \t \t \t obj.find( 'blanket_fold ')。ATTR(' 類, 'blanket_unfold') \t \t \t \t \t \t \t \t obj.find('。PROD')。ATTR( '類', 'prod_under'); \t \t \t \t \t \t \t} \t \t \t \t \t} \t \t \t \t \t}); – uppaljaskaran

回答

0

IE對元素id很嚴格,查找元素的重複id。 FF通常會忽略它們,但IE不會。

0

請包括您調用此函數的代碼部分(設置事件處理函數),否則很難在沒有該函數的情況下找到問題。你有一些奇怪的選擇器,但它們可能是正確的,這取決於你的HTML。

注意,因爲jQuery的1.6,使用prop()編輯屬性,如checked時,建議的attr()代替。

相關問題