简体   繁体   中英

Making 2 ajax request for bash treatment

I'm making an ajax request which is making bash treatment. Another action in my page uses an ajax request but this one is waiting the end of my first request for making what I'm asking. Do you have any idea for doesn't waiting the end of the first ajax request ?

Thanks for your help :)

 $.ajax({
            type: 'POST',
            url: 'make-traitement.html',
            data: { fichier:  fileol, id: idcr }
            });

jQuery's $.ajax has an optional parameter: async

If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

Your final code with asynchronous AJAX call would be:

$.ajax({
    type: 'POST',
    async: false,
    url: 'make-traitement.html',
    data: { fichier:  fileol, id: idcr }
});

This behaviour is due to sessions. Php can`t start second session (with the same session name) while the first one is not closed yet. As far as I know there is no way to avoid this lock.

Try to use the following function asap to free the session files in order to allow second request to be performed.

session_write_close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM