javascript - 未捕获的范围错误: Maximum call stack size exceeded - ajax

标签 javascript jquery

我收到最大调用堆栈错误,但无法找出原因。它说 jquery 并且只有我使用的 jquery 是用于我的 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"; 
    }

}

最佳答案

谢谢大家,

看起来添加一些 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;
    }

关于javascript - 未捕获的范围错误: Maximum call stack size exceeded - ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42633233/

相关文章:

javascript - 从谷歌加载 jquery 不起作用(对我来说)

jquery - 使用 jquery 将某些内容 append 到选定的文本

javascript - 如果用户点击多次,如何阻止 .click 函数被多次触发

javascript - 如何将值从数据库传递到 jquery datepicker 以打开警报?

javascript - javascript函数也是一种对象吗?

javascript - 无法调试卡在 firefox 扩展中的 $.post

javascript - 从nodejs中的url读取图像

javascript - 单击图像后如何播放/启动 youtube 视频?

php - 如何将时间选择器添加到jquery jtable?

javascript - ERROR 错误。GrailsExceptionResolver - 处理请求 : [GET] 时发生 NullPointerException