Sending data recursively using jquery $.ajax gives stack overflow error..

Posted by Rosdi on Stack Overflow See other posts from Stack Overflow or by Rosdi
Published on 2010-04-09T04:59:33Z Indexed on 2010/04/09 5:03 UTC
Read the original article Hit count: 315

Filed under:
|

Why am I getting "too much recursion" error when I do the following?

    function sendTheNames() {

       alert("start submitting names..");

        return function (array) {

            var name = $(array.shift()).text();

            $.ajax({
                url: "test.jsp?name=" + name,
                complete: function () {
                    if (array.length > 0) {
                        return arguments.callee(array);
                    }
                }
            });
        };

    }

    $(document).ready(function () {

        var selectedNames = [];
        $('ul li input:checked').each(function () {
            selectedNames.push($(this).parent());
        });

        alert("begin");

        sendTheNames()(selectedNames);

        alert("done");
    }); 

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about recursion