AJAX中GET和POST方法的区别
来源:互联网 发布:windows桌面草原 编辑:程序博客网 时间:2024/06/05 05:54
<!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=gb2312" />
<title>Send Request Data Using GET and POST http://</title>
<script type="text/javascript">
<!--
var oHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
oHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
oHttp=new XMLHttpRequest();
}
}
function createQueryString()
{
var firstName=document.getElementById("firstName").value;
var middleName=document.getElementById("middleName").value;
var birthday=document.getElementById("birthday").value;
var QueryString="firstName="+firstName+"&middleName="+middleName+"&birthday="+birthday;
return QueryString
}
function doRequestUsingGET()
{
createXMLHttpRequest();
var queryString="Handler.ashx?";
queryString=queryString+createQueryString()+"&timeStamp="+new Date().getTime();
oHttp.onreadystatechange=handleStateChange;
oHttp.open("GET",queryString,true);
oHttp.send(null);
}
function doRequestUsingPOST()
{
createXMLHttpRequest();
var url="Handler.ashx?timeStamp="+new Date().getTime();
var queryString=createQueryString();
oHttp.onreadystatechange=handleStateChange;
oHttp.open("POST",url,true)
oHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
oHttp.send(queryString);
}
function handleStateChange()
{
if(oHttp.readyState==4)
{
if(oHttp.status==200)
{
parseResults();
}
}
}
function parseResults()
{
var responseDiv=document.getElementById("serverResponse");
if(responseDiv.hasChildNodes())
{
responseDiv.removeChild(responseDiv.childNodes[0]);
}
var responseText=document.createTextNode(oHttp.responseText);
responseDiv.appendChild(responseText);
}
//-->
</script>
</head>
<body>
<h1>Enter your first name,middle name,and birthday:
</h1>
<table>
<tbody>
<tr>
<td>First name:</td>
<td><input id="firstName" type="text" /></td>
</tr>
<tr>
<td>Middle name:</td>
<td><input id="middleName" type="text" /></td>
</tr>
<tr>
<td>birthday:</td>
<td><input id="birthday" type="text" /></td>
</tr>
</tbody>
</table>
<form action="#">
<input type="button" value="Send parameters using GET" onclick="doRequestUsingGET();" />
<br />
<br />
<input type="button" value="Send parameters using POST" onclick="doRequestUsingPOST();" />
</form>
<br />
<h2>Server Response:</h2>
<div id="serverResponse"></div>
</body>
</html>
- AJAX中GET和POST方法的区别
- ajax中get和post的区别
- Ajax中Get和Post的区别
- ajax中get和post的区别
- ajax中get和post的区别
- ajax中get和post的区别
- ajax中get和post的区别
- Ajax中POST和GET的区别
- Ajax中Post和Get的区别
- Ajax中Post和Get的区别
- Ajax中POST和GET的区别
- Ajax中POST和GET的区别
- Ajax中Get和Post的区别
- Ajax中POST和GET的区别
- Ajax中POST和GET的区别
- ajax中get和post的区别
- ajax 中post与get方法提交的区别
- Ajax中Get请求和Post请求的区别
- 一份比较详细的DOS命令说明!
- 怎样在驱动层和应用层建立准消息机制(转)
- IBM WebSeal实例配置文件webseald-实例名.conf
- Spring AOP 的proxy详解
- VC操作Excel——打印预览
- AJAX中GET和POST方法的区别
- 我写的一个触发器的小例子
- 切分窗口
- 中国十大肉身菩萨
- IT从业人员必看的10个论坛
- 心寒啊!!! 养一窝专家不如养只癞蛤蟆管用!!!
- 博客开通第一贴。
- 自定义实体类简介
- VC操作Excel——插入图片以及对图片的修改