Stack Overflow in IE with JQuery (at line 12/1076)

Deadly 提交于 2019-12-20 07:26:37

问题


I'm using JQuery from Google CDN and I've been getting stack overflow error (using IE8) at lines 12 (for the min file) and 1076 (for the uncompressed one). The JQuery code at the line where stack overflow error takes me to is:

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;
},

...

Here's my code: ...

  $(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;
    });
  });

The Error is coming up while Submitting the form. I can't see any recursive code in here that'd make IE8 start crying about running out of stack?

Thanks, Dw.


回答1:


You are calling $("#newcmpgn").submit(); inside the submit function.

That looks recursive to me!



来源:https://stackoverflow.com/questions/1768855/stack-overflow-in-ie-with-jquery-at-line-12-1076

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!