Force a 200 header in Ajax while the PHP function goes to sleep

2

I am creating a chat function, however, the server is waiting for a DB interaction for a period of 10 seconds.

The problem is that while the Ajax connection is open waiting for a response within 10 seconds, the browser does not accept to switch pages.

I noticed that Facebook sends a 200 header and keeps the connection open, so this kind of problem does not happen.

Does anyone know how I can force a header response?

    
asked by anonymous 23.10.2014 / 19:52

1 answer

3

Facebook chat uses an asynchronous web framework made in Python, Tornado . The concept of asynchronous servers is different, since the whole process is done by stream connections. This concept is also used in Node.js servers (already by the asynchronous nature of javascript).

If your goal is to chat, you can use the Socket.io port for PHP Elephant.io . I did not use the port for PHP, only the original (from Node.js), but he's really good at it! ;)

    
03.11.2014 / 20:05