简体   繁体   中英

More efficient ajax & php interaction

I'm trying to find more efficient ways to build my site. I'm currently using an ajax $.post in a setInterval() function to reload the content.

Something like this:

 $(document).ready(function() {
   $("#data").load("data.php");

   var refreshId = setInterval(function() {
      $("#data").load('data.php');
   }, 1000);

 });

But this is too heavy with a lot of users online. I would like something like this: https://yobit.net/en/dice/

I have no idea how it is made, and what language they used for it. I would be glad if someone help me discover what is this or point me to an language or method to do something like it.

Sorry for my bad english, not first language.

Thank you :)

I think you need to know about websocket.

You can use websocket by workerman or swoole .

If you think websoket is inconvenient, ajax long polling also can help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM