doucepei5298 2018-06-06 11:40
浏览 51

浏览器在服务器端锁定来自异步请求的昂贵进程

So I have a quite expensive and complex PHP process which makes its execution long lasting, lets call it function "expensive_process()".

I have an interface which through a press of a button calls an ajax request to a PHP script which in turn initiates "expensive_process()". Here's the javascript code:

$('#run_expensive_process_button').click( function(){

  var url = "initiate_expensive_process.php";

  $.ajax({
    url: url
  });

});

And initiate_expensive_process.php code:

<?php
  session_start();    

  run_expensive_process();
?>

Simple and trivial. Now the issue with this is that while expensive_process() is running, the browser is losing the ability to navigate the domain. If I refresh the browser window it hangs indefinitely while the process last. If I redirect to a different url under the same domain, same thing. This happens in all browsers. However, if I relaunch the browser (close and open a new window, not a tab), navigation works normally, even though expensive_process() is still running.

I've inspected network traffic, and the HTTP request to initiate_expensive_process.php doesn't get a response while expensive_process() is running, but I'm assuming this shouldn't be locking the browser given the asynchronous nature of the request..

One more thing, which I believe is relevant. This situation is happening on a replica server. On my local machine, where I run WAMP and the same source code, this is not happening, i.e., while expensive_process() is running, I'm still able to navigate the hosting domain without having to relaunch the browser. This seems to be an indication of a server configuration problem of some sort, but I'm not sure I can rule out other possible reasons.

Anyone know what might be causing this or what can be done to figure out the source of the problem?

Thanks

  • 写回答

2条回答 默认 最新

  • duanbarong4617 2018-06-06 11:54
    关注

    I wonder whether it might be due to ajax. The javascript is being executed client-side. Maybe you might consider a stringified JSON call instead of ajax?

    评论

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。