Ajax request are not async

后端 未结 4 974
既然无缘
既然无缘 2021-01-06 09:48

I have an ajax problem:

foreach(ids as id){
  $.ajax({
    url:\'script.php\',
    data:\'id=\'+id,
    cache:false,
  });
}

If I loop 6 ti

4条回答
  •  迷失自我
    2021-01-06 10:39

    Ok thanks. After some hours of analysing and reflecting I realized why this script goes syncronsly: I open the script.php file and I notice this and the beginig of the file:

    
    

    So I have parallel ajax calls to a php script that uses session, but sessions in this case locks the calls to be executed syncrosnly cause of the session vars request, so the solution of this problem is:

    
    

    With session_write_close i have my script to make the ajax calls in async way. a good explain here http://konrness.com/php5/how-to-prevent-blocking-php-requests/

提交回复
热议问题