2017-03-06 71 views
1

我收到最大的調用堆棧錯誤,無法找出原因。它說jQuery的,我只使用jQuery是我的AJAX ....未捕獲的RangeError:超出的最大調用堆棧大小 - ajax

jquery.min.js:6未捕獲的RangeError:最大調用堆棧大小超過

這裏是我的代碼

function processPhase3(){ 
    client_info.primary_email = _("emailAddress").value; 
    client_info.phone = _("cphone").value; 
    client_info.primary_text = _("cphone").value; 
    client_info.primary_voice = _("cphone").value; 
    client_info.hphone = _("cphone").value; 
    client_info.agree = _("agree"); 

    // if check true 
    // then check if email or number in the text field 
    if(client_info.agree.checked == false){ 
     _("alertThree").style.display = "block";  
    }else{ 
     _("alertThree").style.display = "none"; 
    } 
    if(client_info.phone.length > 3 || client_info.primary_email.length > 3){ 
     _("alertFour").style.display = "none"; 
     _("phase3").style.display = "none"; 
     _("phase4").style.display = "block"; 
     _("progressBar").classList.remove("progress-bar-success"); 
     _("progressBar").className += ' progress-bar-success'; 
     _("progressBar").style.width = '100%'; 
     _("status").innerHTML = "Congratulations!"; 
      $.ajax({ 
      type: 'POST', 
      data: client_info, 
      url: "my_prefs_save.php" 
     }); 
    }else{ 
     _("alertFour").style.display = "block"; 
    } 

}

+0

其中是client_info實例化?你能告訴我們一個console.log(client_info)的樣子嗎? –

+1

供您參考http://stackoverflow.com/questions/6095530/maximum-call-stack-size-exceeded-error – CaptainHere

+0

您可以查看錯誤中提供的堆棧跟蹤以瞭解問題的起源地點嗎? –

回答

0

謝謝你們,

看起來增加了一些return語句解決了這個問題;)

function processPhase3(){ 
    client_info.primary_email = _("emailAddress").value; 
    client_info.phone = _("cphone").value; 
    client_info.primary_text = _("cphone").value; 
    client_info.primary_voice = _("cphone").value; 
    client_info.hphone = _("cphone").value; 
    client_info.agree = _("agree"); 

    // if agree check is true - proceed if countOne = 1, false turn on error 
    // if pn or email exist - proceed countTwo = 1, else turn on error 
    // then check if email or number in the text field 
    if(client_info.agree.checked == true){ 
     _("alertThree").style.display = "none"; 
    }else{ 
     _("alertThree").style.display = "block"; 
     return; 
    } 
    if(client_info.phone.length > 3 || client_info.primary_email.length > 3){ 
     _("alertFour").style.display = "none"; 
     _("phase3").style.display = "none"; 
     _("phase4").style.display = "block"; 
     _("progressBar").classList.remove("progress-bar-success"); 
     _("progressBar").className += ' progress-bar-success'; 
     _("progressBar").style.width = '100%'; 
     _("status").innerHTML = "Congratulations!"; 
      $.ajax({ 
      type: 'POST', 
      data: client_info, 
      url: "my_prefs_save.php" 
     }); 
    }else{ 
     _("alertFour").style.display = "block"; 
     return; 
    } 
相關問題