<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ajax test</title> <link type='text/css' rel='stylesheet' href='../css/ajax.css' /> </head> <body> <div id='root'></div> <div id='content'></div> <script type="text/javascript"> var http; http=new XMLHttpRequest();//had got function chuli(url){ http.onreadystatechange=showcnt(); http.open('GET',url); http.send(); } function showcnt(){ if(http.readyState===4){ if(http.status===200){ document.getElementById('content').innerHTML=http.responseText; } } } document.getElementById('root').onclick=function(){chuli('data.txt');}; </script> </body> </html> firfox核心可以运行 ie下加载上ie的httpRequest就可以了 |
|
来自: 竹林书屋@ > 《JavaScript》