1.介绍

  

2.方法

  

  

3.程序位置设计

  

4.程序(针对XMLHttpRequest)

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
window.onload=function(){
document.getElementsByTagName("a")[0].onclick=function(){
//new XMLHttpRequest
var request=new XMLHttpRequest(); var url=this.href;
var method="GET"; request.open(method,url);
request.send(null); request.onreadystatechange=function(){
if(request.readyState==4){
if(request.status==200||request.status==304){
alert(request.responseText);
}
}
}
return false;
}
}
</script>
</head>
<body>
<a href="helloAjax.txt">hello click</a>
</body>
</html>

二.解释

1.发送函数

  

2.onreadystatechange处理函数

  

3.open方法

  

三:相应接受

1.接受函数

  

2.readState

  

3.reponseText方法

  

4.reponseXML

  

四:添加时间戳

1.url

  var url=this.href+"?time="+new Date();

五:注意点(post方法)

1.知识点

  

2.程序

 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
window.onload=function(){
document.getElementsByTagName("a")[0].onclick=function(){
//new XMLHttpRequest
var request=new XMLHttpRequest(); var url=this.href;
var method="POST"; request.setRequestHeader("ContentType","application/x-www-form-urlencoded"); request.open(method,url);
request.send("name='tom'"); request.onreadystatechange=function(){
if(request.readyState==4){
if(request.status==200||request.status==304){
alert(request.responseText);
}
}
}
return false;
}
}
</script>
</head>
<body>
<a href="helloAjax.txt">hello click</a>
</body>
</html>

001 Ajax中XMLHttpRequest的讲解的更多相关文章

  1. 第108天:Ajax中XMLHttpRequest详解

    在Ajax应用程序中,XmlHttpRequest对象负责将用户信息以异步通信地发送到服务器端,并接收服务器返回的响应信息和数据. XMLHttpRequest可以提供不重新加载页面的情况下更新网页, ...

  2. Ajax 之XMLHttpRequest讲解

    一直以来都听别人说Ajax,今天终于接触到了.......... 一.什么是Ajax? 答: AJAX即“Asynchronous Javascript And XML”(异步JavaScript和X ...

  3. AJAX跨域完全讲解

    AJAX跨域完全讲解 今天在慕课网上学习了AJAX跨域完全讲解:https://www.imooc.com/learn/947 我在收集AJAX面试题的时候其实就已经有过AJAX跨域的问题的了,当时候 ...

  4. AJAX初探,XMLHttpRequest介绍

    AJAX初探,XMLHttpRequest介绍 AJAX      AJAX = Asynchronous JavaScript and XML. 异步的JavaScript和XML.      AJ ...

  5. 转:AJAX中xhr对象详解

    XJAX ,并不是一种新技术的诞生.它实际上代表的是几项技术按一定的方式组合在一在同共的协作中发挥各自的作用. 它包括: 使用XHTML和CSS标准化呈现: 使用DOM实现动态显示和交互: 使用XML ...

  6. Ajax中的get和post两种请求方式的异同

    Ajax中我们经常用到get和post请求.那么什么时候用get请求,什么时候用post方式请求呢? 在做回答前我们首先要了解get和post的区别.   1. get是把参数数据队列加到提交表单的A ...

  7. 转:Ajax中的get和post两种请求方式的异同

    1. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到.post是通过HTTP post机制,将表单内各个字段与其内容放置在HTML ...

  8. Egret和Http请求 (Ajax、XMLHttpRequest、Post、Get)

    一  Http请求 二  AJax和XMLHttpRequest 三  一个Ajax例子 四 Egret中的egret.HttpRequest 五 Post和Get区别 一 Http请求 Http深入 ...

  9. ajax中网页传输(一)TEXT——带有删除功能的数据库表格显示练习

    网页之间传输的三种方式:TEXT.JSON.XML. 本章将讲解带有TEXT形势的ajax网页传输 第一:body部分代码 <title>ajax中TEXT讲解并且带有删除功能的表格< ...

随机推荐

  1. BZOJ 3625: [Codeforces Round #250]小朋友和二叉树

    3625: [Codeforces Round #250]小朋友和二叉树 Time Limit: 40 Sec  Memory Limit: 256 MBSubmit: 304  Solved: 13 ...

  2. luogu2038 [NOIp2014]无线网络发射器选址 (前缀和)

    貌似不用做前缀和也能过? #include<bits/stdc++.h> #define pa pair<int,int> #define CLR(a,x) memset(a, ...

  3. 简单的sql分组统计

    一个记录员工打卡时间的表,只有两个有效字段 员工名称,打卡时间,现在要统计某一天中,每个员工的打卡次数.最早打卡时间.最晚打卡时间,问sql怎么写? 其实这个sql很简单, 1.首先要明确既然是按每个 ...

  4. 【leetcode】Path Sum2

    Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given su ...

  5. 位运算符和unity Layers

    按位运算符:与(&).非(~).或(|).异或(^).<<(左移).>>(右移).位运算符主要用来对二进制位进行操作. 逻辑运算符:&&.||.!.逻辑 ...

  6. java基础-网络编程(Socket)技术选型入门之NIO技术

    java基础-网络编程(Socket)技术选型入门之NIO技术 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.传统的网络编程 1>.编写socket通信的MyServer ...

  7. Apache 与 Tomcat 整合

    目标 1.同一台机器上,不同的域名指向,访问不同的项目,即: (1)one.test.com 访问 project_one (2) two.test.com 访问 project_two   2.将T ...

  8. Spring Boot 1.4 单元测试

    在1.3中单元测试这样子的类似代码: // SpringJUnit支持,由此引入Spring-Test框架支持! @RunWith(SpringJUnit4ClassRunner.class) // ...

  9. bzoj千题计划258:bzoj3123: [Sdoi2013]森林

    http://www.lydsy.com/JudgeOnline/problem.php?id=3123 启发式合并主席树 #include<cmath> #include<cstd ...

  10. crontab定时任务2_net

    2017年2月25日, 星期六 crontab定时任务2_net 1.先来一个小小的例子 查看当前路径: [root@root test]# pwd /home/admin/test [root@ro ...