jquery - Apache PHP looping, will it block other accesses to the server? -
i'm using phalcon framework build server, , i'm trying implement loop in function.
for example, user gives input page, page uses ajax post input url of server, url on server doing looping work lasts 3 seconds.
besides, page use ajax send url of server, in order progress of looping. stored progress in session.
however, seems when server doing looping, can't respond other requests. observed, can see 2nd ajax sent multiple times, log got indicates function 2nd url called once.
is limitation of phalcon? php? apache? or doing wrong configuration?
some demo code shown here:
javascript
function query(point) { $.ajax( { url: "/work", type: 'post', datatype: 'json', data: {...}, success: function(data, status) { alert(data); if(progressinterval) { clearinterval(progressinterval); alert("finished"); } }, error: function(err) { if(progressinterval) { clearinterval(progressinterval); ertal("err"); } } }); progressinterval = setinterval(function() { alert("send"); $.ajax( { url: "/loadprogress", type: 'get', datatype: 'text', success: function(data) { alert(data); } }); }, 100); };
work.php
function work() { for($i=0;$i<3000;$i++) { work; store $i in session; } echo "finished"; }
loadprogress.php
function loadprogress() { $i session; echo $i/3000; }
i found missed here. after writing session, must call session_write_close(). or whole server locked on session.
Comments
Post a Comment