AJAX memory leak

I am using jQuery 3.1.0 and UWamp 3.1.0 to run this script.

I want to create a script that can connect to a server to complete a chain of repetitive tasks; This server does not belong to my domain.

I will only send code starting with AJAX calls, as I think these are the ones that cause leaks

This first part connects to the previously calculated link and loads a list of other links to connect (the parser simply returns the contents of the given URL).

$.post("php/parser.php", {
    url: uri
}, function(res, status) {
    // Parsing

The answer always contains several links, and I need to connect to the first, make a few more calls, and only then can I go to the second, then to the third, etc.
Links are stored in the URLs of the array.

    // Connects to the first link in the list
    console.log("Request to: " + urls[0]);
    urls[0] = $.post("php/parser.php",
        {
            url: urls[0]
        },
        function(res, state) {
            console.log(0 + ": completed");
        }
    );
    for(var y = 0; y < urls.length;/*y++*/) {
        $.when(urls[y]).done(function(res) {
            // Other calls here
            console.log("Doing stuff");
            // Continuing with the next link
            y++;
            if(y < urls.length) {
                console.log("Request to: " + urls[y]);
                urls[y] = $.post("php/parser.php",
                    {
                        url: urls[y]
                    },
                    function(res, state) {
                        console.log(y + ": completed");
                    }
                );
            }
        }, function(res) {});
    }
});

: Chrome/IE , $when (urls [y]). Done() , URL- [0].state() .

Firefox, , (, f10, , 6 ), , , console.log(), , , ( ), , 30 .
, ; script, Firefox 480 :
debug- > 500 6s
→ 7 30
( , - )

js/jQuery/php, - ; - , , . .

: , ,

+4

Source: https://habr.com/ru/post/1650412/


All Articles