<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Document</title> </head> <body> </body> <script type="text/javascript"> var ajax = new XMLHttpRequest(); ajax.open('get','./ajax.php?name=list',true); ajax.send(); ajax.onreadystatechange = function(){ if(ajax.readyState == 4 && ajax.status == 200){ var result = ajax.responseText; alert(result); } } </script> </html>
点击 "运行实例" 按钮查看在线实例