使用JQuery在IE中进行堆栈溢出(第12/1076行)

时间:2009-11-20 07:14:00

标签: javascript jquery stack-overflow

我正在使用来自Google CDN的JQuery,我在第12行(对于min文件)和1076(对于未压缩的文件)中遇到了堆栈溢出错误(使用IE8)。堆栈溢出错误带给我的行的JQuery代码是:

的jquery.js ...

makeArray: function( array ) {
    var ret = [];

    if( array != null ){
        var i = array.length;
        // The window, strings (and functions) also have 'length'
        // @ALL : this is the line i am getting error on ...
        if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval )
            ret[0] = array;
        else
            while( i )
                ret[--i] = array[i];
    }

    return ret;
},

...

这是我的代码: ...

  $(document).ready(function(){
    $("#newcmpgn").validate({ 
      errorElement:'dt', 
      rules:{agree: "required"},
      messages:{agree: "You need to accept to Terms and Conditions in order to continue."}
    });
    $("#newcmpgn").submit(function(){
      if($("#newcmpgn").valid()){
        var ubal = Number($("#userbalance").val());
        var camt = Number($("#amount").val());
        if(ubal > camt){
          $("#newcmpgn").attr('action', '<?= site_url('account/payments/actpayment/'.$cmpgn_id) ?>');
          return true;
        }
        if($("#autorenew").attr('value') == 'Y'){
          $("#newcmpgn").attr('action', '<?= site_url('account/payments/makepayment/'.$cmpgn_id) ?>');
        }else{
          $("#newcmpgn").attr('action', '<?= site_url('account/payments/makesinglepayment/'.$cmpgn_id) ?>');
        }
        $("#newcmpgn").submit();
        return true;
      }
      return false;
    });
  });

提交表单时出现错误。我在这里看不到任何递归代码会让IE8开始为堆栈耗尽而哭泣?

谢谢, DW传递。

1 个答案:

答案 0 :(得分:2)

您正在提交函数中调用$("#newcmpgn").submit();

这对我来说是递归的!