The first, thank you for see this my post, I use AJAX to send request to server PHP (laravel) and the server will handle request (about 10sec) before return it for AJAX. But, when AJAX request waiting, I open other browser to access my webpage -> It still wait for 10s. I don't understand??? My js
function pullRequest() {
/* send request to server */
var xhr = $.ajax({
method: 'POST',
url: 'pull?random_key='+Math.floor(Math.random()*10),
data: {'_token':$('meta[name=csrf-token]').attr('content')},
success: function(response) {
/* pull request */
pullRequest();
},
}); /* end ajax */
$('a[href]').click(function() {
xhr.abort();
});
} /* end function pullRequest */
$(function() {
// pullRequest();
setTimeout('pullRequest()', 2000);
});
My php
public function handle(Request $request) {
$time = time()+50;
while(1) {
echo connection_status();
if($this->hasNewMessages() || time() >= $time) {
break;
}
continue;
}
return $this->messages;
}
I have record a video about it. I am sorry, cause I don't know insert it. Please, follow link youtube: https://www.youtube.com/watch?v=8jqPU3R-60I
Thank you for reading
</div>