2012-11-14 46 views
4

我收到來自Firefox的錯誤Internal Error: too much recursion。我正在嘗試使用jquery進行ajax調用。使用Internet Explorer它工作正常。Firefox內部錯誤:遞歸太多

我沒有遞歸調用任何函數。

請給我一些建議。由於

$(function(){ 
     $('#delivery').accordion({ 
      header: '.accTrigger', 
      autoHeight: false, 
      animated: 'easeslide', 
      change: function(event, ui) { 
       alert("here"); 
       event.preventDefault(); 
       $.ajax({ 
        url: URL, 
        type: 'GET', 
        dataType: 'html', 
        timeout: 18000, 
        success: function(data, textStatus, xhr) { 
          alert("sus"); 
        }, 
        error: function(xhr, textStatus, errorThrown) { 
          alert("err" + errorThrown); 
        } 
       });  

       $("input",ui.newHeader).prop("checked","checked"); 
       $("input",ui.newHeader).trigger('click'); 

       $(".accSection").each(function() { 
        $(this).removeClass("active"); 
       }); 

       ui.newHeader.parent().addClass("active"); 
       fitContentBackground(); 
      } 
     }); 

     /** 
     * Loop through all the payment types and enable the respective accordin 
     */ 
     $.each($('.accSection'), function(index, value) { 
      if ($('input[type="radio"]', value).is(':checked') == true) { 
       $('#delivery').accordion('activate',index); 
       $(this).addClass("active"); 
      } 
      else { 
       $(this).removeClass("active"); 
      } 
     }); 
}); 

感謝所有

我爲增加整個代碼遺憾的響應,就引發如此多的困惑..

即使這樣簡單的片斷也產生了同樣的錯誤(InternalError該:太的遞歸)

$(document).ready(function() { 
$("#buttontest123").click(function(evt){ 
    alert("herepavan"); 
    evt.preventDefault(); 

    setPayment(); 




}); 

function setPayment() 
{ 
     alert("here1"); 
    $.ajax({ 
     url: 'URL', 
     type: 'GET', 
     dataType: 'html', 

     success: function(data, textStatus, xhr) { 

      alert("sus"); 
     }, 
     error: function(xhr, textStatus, errorThrown) { 
      alert("err"+errorThrown); 
     } 
    }); 


} 

}); 

</script> 
+3

我只是猜測這裏,因爲我不不知道你使用的是什麼插件...你有一個改變回調,我猜是每當手風琴改變時都會觸發。在這個回調中,你改變了東西(添加/刪除類等)。難道他們被認爲是變化,再次觸發變化 - 回調 - 讓你陷入無限循環? –

+0

感謝您的回覆。沒有ajax腳本,我沒有收到任何錯誤。這個錯誤也來自錯誤函數。 – user1823065

回答

3

我想觸發click事件在newHeader元素的元素會引起變化事件(W HICH會recusive)

$("input",ui.newHeader).trigger('click'); 

嘗試更換其他任何邏輯(不觸發「單擊」上面的行,就打電話給你想要的代碼)

+0

嗨MhdSyrwan,由於我更新了最近的代碼片段沒有任何點擊事件,但仍然是拋出同樣的例外..請讓我知道你的進一步輸入 – user1823065

+0

我測試了你的新片段..它的工作沒有任何投擲例外! – MhdSyrwan