<! DOCTYPE html>
<meta charset= "UTF-8";
<title></ Title>
<script src= "13ajax.js" ></SCRIPT>
<script>
Window.onload=function () {
var Obtn=document.getelementbyid (' btn1 ')
Obtn.onclick=function () {
SetInterval (function () {
Ajax (' Get ', ' Getdata.php ', ', function (data) {
var data=json.parse (data);
var Oul=document.getelementbyid ("Ul1")
Var Html= '
for (var i=0;i<data.length;i++) {
html+= ' <li><a href= ' "> ' +data[i].title+ ' </a>[ <span> ' +data[i].data+ ' </span>]</li> '
}
oul.innerhtml=html;
}
},4000)
}
}
</script>
<body>
<input type= "button" value= "Get" Id= "Btn1",
<ul id= "UL1";
</ul>
<!--Ajax ({
Type: ' Get ',
URL: ' getdata.php ',
Data: ",
Success:function () {
}
})--
</body>
getdata.php Content
<?php
Header ("content-type:text/html;charset= ' Utf-8 '");
error_reporting (0);
$new = Array (
Array (' title ' = ' + ' meets Chinese and foreign correspondents at Xiamen International Conference Center ', ' data ' = ' 2017-9-19 '),
Array (' title ' = ' = ' Yesterday, BRICS leaders Xiamen meeting successfully concluded ', ' data ' = ' 2017-2-12 '),
Array (' title ' = ' China held ' dialogue with emerging markets and developing countries ', ' data ' = ' 2017-7-12 '),
The array (' title ' = ' + ' sends a strong signal of deepening cooperation and global development ', ' data ' = ' 2017-6-21 '),
Array (' title ' = ' + ' together out of an innovative, coordinated, green, open ', ' data ' = ' 2017-10-21 '),
Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),
Array (' title ' = ' + ' together to drive the BRICS partnership to move forward ', ' data ' = ' 2017-9-3 '),
Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),
Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),
Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),
Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 '),
Array (' title ' = ' = ' next year, South Africa will be the BRICS presidency ', ' data ' = ' 2017-9-12 ')
);
echo Json_encode ($new);
?>
Effect:
Ajax instant Update get data combined with Ajax JS reference use of course need to build local environment and create PHP