Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7202421
  • 博文数量: 510
  • 博客积分: 12019
  • 博客等级: 上将
  • 技术积分: 6836
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-01 16:46
文章分类

全部博文(510)

文章存档

2022年(2)

2021年(6)

2020年(59)

2019年(4)

2018年(10)

2017年(5)

2016年(2)

2015年(4)

2014年(4)

2013年(16)

2012年(47)

2011年(65)

2010年(46)

2009年(34)

2008年(52)

2007年(52)

2006年(80)

2005年(22)

分类: Python/Ruby

2020-12-02 18:11:32

可快速搭建,用于页面测试

python2
python -m SimpleHTTPServer 端口号


python3
python -m http.server 端口号


运行下目录新建一个测试文件test.html.来测试ajax

点击(此处)折叠或打开

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script>
  6. function loadXMLDoc()
  7. {
  8.   var xmlhttp;
  9.   if (window.XMLHttpRequest)
  10.   {
  11.     // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
  12.     xmlhttp=new XMLHttpRequest();
  13.   }
  14.   else
  15.   {
  16.     // IE6, IE5 浏览器执行代码
  17.     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  18.   }
  19.   
  20.   xmlhttp.onreadystatechange=function()
  21.   {
  22.     if (xmlhttp.readyState==4 && xmlhttp.status==200)
  23.     {
  24.       document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
  25.     }
  26.   }
  27.   
  28.   
  29.   xmlhttp.open("GET","",true);
  30.   xmlhttp.send();
  31. }
  32. </script>
  33. </head>
  34. <body>

  35. <h2>AJAX</h2>
  36. <button type="button" onclick="loadXMLDoc()">请求数据</button>
  37. <div id="myDiv"></div>
  38.  
  39. </body>
  40. </html>



阅读(1207) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~