0

I have been looking for several answers around the web and here, but I could not find one that solved my problem.

I am making several JQuery ajax calls to the same PHP script. In a first place, I was seeing each call beeing executed only after the previous was done. I changed this by adding session_write_close() to the beginning of the script, to prevent PHP from locking the session to the other ajax calls. I am not editing the $_SESSION variable in the script, only reading from it.

Now the behaviour is better, but instead of having all my requests starting simultaneously, they go by block, as you can see on the image:

Request timeline

What should I do to get all my requests starting at the same moment and actually beeing executed without any link with the other requests ?

For better clarity, here is my js code:

        var promises = [];
        listMenu.forEach(function(menu) {
            var res = sendMenu(menu);//AJAX CALL
            promises.push(res);
        });
        $.when.apply(null, promises).done(function() {
            $('#ajaxSpinner').hide();
            listMenu = null;
        });

My PHP script is just inserting/updating data, and start with:

<?php

session_start();
session_write_close();

//execution

I guess I am doing things the wrong way. Thank you in advance for you precious help !!

Thomas

1

1 Answer 1

1

This is probably a browser limitation, there is a maximum number of concurrent connections to a single server per browser instance. In Chrome this has been 6, which reflects the size of the blocks shown in your screenshot. Though this is from 09, I believe it's still relevant: https://bugs.chromium.org/p/chromium/issues/detail?id=12066

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, all browsers have limitations on the concurrent requests: stackoverflow.com/q/561046/1220930, stackoverflow.com/q/985431/1220930
Thanks both of you for you answers. I was unaware of the browser limitation. I guess I will keep the things the way they are for now, until I find something better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.