Get the App
SLTechnology News&Howtos  ›  Development  › 

How to refresh php+ajax in real time

Shulou Source: shulou.com Published: 2022-06-03 19:47:42 11月12日 Update

This article will explain in detail how to refresh php+ajax in real time. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The details are as follows:

Ajax automatic refresh seems to be a very common problem, and it was also stuck to do a web chat room program before. After a period of study, I finally made a code framework that can automatically refresh the web page. I hope that my lost relatives will not take so many detours like me.

Html section:

Function loadXMLDoc () / / ajax sends the request and displays {var xmlhttp; if (window.XMLHttpRequest) {/ / code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest ();} else {/ / code for IE6, IE5 xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function () {if (xmlhttp.readyState==4 & & xmlhttp.status==200) {document.getElementById ("myDiv") [xss_clean] = xmlhttp.responseText;} xmlhttp.open ("POST", "/ chat.php", true) Xmlhttp.send (); setTimeout ("loadXMLDoc ()", 1000); / / Recursive call} loadXMLDoc (); / / execute first

Tags: Real-time web pages articles more parts good practical confused code content just common detours manual articles time frames ongoing knowledge programs Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS NVidia MySQL Shulou Technology Linux