zoukankan      html  css  js  c++  java
  • Ajax-Demo

    index.jsp 
    1
    <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <title>Insert title here</title> 8 <script type="text/javascript"> 9 window.onload=function(){ 10 //1.获取a节点,并对其添加onclick响就函数 11 document.getElementsByTagName("a")[0].onclick=function(){ 12 //3.创建一个XMLHttpRequest对象 13 var request=new XMLHttpRequest(); 14 //4.准备发送请求的数url,加上时间戳 15 var url=this.href +"?time=" + new Date(); 16 var method="GET"; 17 //5.调用XMLHttpRequest的open方法 18 request.open(method,url); 19 //6.调用XMLHttpRequest的send方法 20 request.send(null); 21 //7.为XMLHttpRequest对象添加onreadystatechange响应函数 22 request.onreadystatechange = function(){ 23 //8.判断响应是否完成:XMLHttpRequest对象的readyState属性为4的时侯 24 if(request.readyState == 4){ 25 //9.再判断响应是否可用:XMLHttpRequest对象status属性值为200 26 if(request.status == 200||request.status == 304){ 27 //10.打印响 应结果:reponseText 28 alert("aaa") 29 alert(request.responseText); 30 } 31 } 32 } 33 //2.取消a节点默认行为 34 return false; 35 } 36 } 37 </script> 38 </head> 39 <body> 40 <a href="test.txt">test helloWord!</a> 41 </body> 42 </html>
    test.txt 
    hello world,the first ajax!
  • 相关阅读:
    uploadify插件的功能应用
    dropify插件的字符串
    VCC、VDD和VSS
    Bootloader升级方式一————擦、写flash在RAM中运行
    Can DBC文件翻译
    CANdbc编辑器的下载和入门介绍
    CAN协议,系统结构和帧结构
    数据帧
    自动驾驶技术之——无人驾驶中的CAN总线
    can物理信号-----------显性和隐性
  • 原文地址:https://www.cnblogs.com/gpdm/p/5851860.html
Copyright © 2011-2022 走看看