Search code examples
formsyii2popupyii2-model

Uncaught RangeError: Maximum call stack size exceeded Yii2 popup form


I have a problem with a pop-up form in Yii2. "Update" is not working. The form is displayed but inspect tool shows:

Uncaught RangeError: Maximum call stack size exceeded.

The action of creating uses the same code and it works perfectly. I do not know what's going on.

$(function(){
$(document).on('click','#modalButton',function(){
    var id = $(this).attr('value');

    $.get('update',{'id':id},function(data){
        $('#modalUpdate').modal('show')
        .find('#modalContentUpdate')
        .html(data);
    });

});

This is my index.php


Solution

  • It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you hit the call stack limit.

    This is almost always because of a recursive function with a base case that isn't being met.

    Viewing the stack

    Consider this code...

    (function a() {
        a();
    })();
    

    The call stack grows until it hits a limit: the browser hardcoded stack size or memory exhaustion.

    In order to fix it, ensure that your recursive function has a base case which is able to be met...

    (function a(x) {
        // The following condition 
        // is the base case.
        if ( ! x) {
            return;
        }
        a(--x);
    })(10);