ajax的post请求
来源:互联网 发布:zip压缩算法 编辑:程序博客网 时间:2024/05/04 08:10
index.jsp:
<%@ page language="java" import="java.util.*" contentType="text/html;charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>123</title>
<script language="javascript">
//定义一个变量用于存放XMLHttpRequest对象
var xmlHttp;
//改函数用于创建一个XMLHttpRequest对象
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
//这是一个启动AJAX异步通信的方法
function ajaxLogin(){
var ln = document.getElementById("returnMes").value;
//创建一个XMLHttpRequest对象
createXMLHttpRequest();
//将状态绑定到一个函数
xmlHttp.onreadystatechange=processAjaxLogin;
//通过GET方法向指定的URL建立服务器的调用
var url="ajaxLogin.action";
xmlHttp.open("post",url,true);
//设置请求头
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//发送请求
xmlHttp.send("responseText="+ln);
}
//这是一个用来处理状态改变的函数
function processAjaxLogin(){
//定义一个变量用于存放 从服务器返回的响应结果
var responseContext="";
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
responseContext = xmlHttp.responseText;
document.getElementById("returnMes").value=responseContext;
}
}
}
</script>
</head>
<body>
<input type="text" id="returnMes">
<input type="button" value="异步请求" onclick="ajaxLogin();">
<table>
<tr>
<td>我是不刷新的</td>
</tr>
<tr>
<td>我是不刷新的</td>
</tr>
<tr>
<td>我是不刷新的</td>
</tr>
<tr>
<td>我是不刷新的</td>
</tr>
<tr>
<td>我是不刷新的</td>
</tr>
<tr>
<td>我是不刷新的</td>
</tr>
</table>
</body>
</html>
其余代码同Ajax的get请求
- ajax的post请求
- ajax的post请求
- Ajax 的POST请求...
- 一个ajax的Post请求
- js的ajax post请求
- Ajax的get/post请求服务器响应
- AJAX的get和post请求详解
- Ajax get,post 的跨域请求
- ajax的GET和POST请求
- AJAX请求 $.post方法的使用
- $.get()/$.post()/$ajax() 异步请求的例子
- AJAX请求 $.post方法的使用
- json格式ajax的post请求方式
- 使用xml格式ajax的post请求
- Ajax的GET和POST请求
- AJAX请求 $.post方法的使用
- AJAX请求 $.post方法的使用
- Ajax请求GET/POST方法的封装
- UVa 10392 - Factoring Large Numbers
- update时连接表
- UNIX传奇[转自酷壳]
- [转]如何让设计动感起来
- vmware tools install
- ajax的post请求
- python 学习笔记
- Red Gate 数据库管理工具说明
- ArcGIS Server清除缓存(Java后台清理缓存方法)
- 批量删除数据库表
- iPhone 文件结构和文件操作
- 白领21条享受生活法则
- Ubuntu命令shutdown 详解
- VC 进程间通信