Phu Master Phu Master - 4 months ago 6
PHP Question

Why is my browser to wait?

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 */
}); /* end ajax */
$('a[href]').click(function() {
} /* 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) {
return $this->messages;

I have record a video about it. I am sorry, cause I don't know insert it. Please, follow link youtube:

Thank you for reading


With the command php artisan serve, you are actually starting PHP's builtin web server.

As noted in the PHP manual:


This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.

If you want a production grade installation or any additional features, you need to use a separate web server such as Apache (which you mistakenly though you were using).