XMLHttpRequst对象的使用
来源:互联网 发布:windows10平板优化版 编辑:程序博客网 时间:2024/05/01 17:51
<!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>
<title>Untitled Page</title>
</head>
<script type="text/javascript" language="javascript">
var xmlHttp;
function createXMLHttpRequest()
{
//在IE下创建XMLHttpRequest对象
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
xmlHttp = null;
}
}
//在Mozilla和Safari等非IE浏览器下创建XMLHTTPRequest对象
if(!xmlHttp && typeof XMLHttpRequest != "undefined")
{
xmlHttp = new XMLHttpRequest();
}
return xmlHttp;
}
function send_request(url)
{
createXMLHttpRequest();
xmlHttp.onreadystatechange = processRequest;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
// 处理返回信息的函数
function processRequest()
{
if (xmlHttp.readyState == 4)
{ // 判断对象状态
if (xmlHttp.status == 200)
{ // 信息已经成功返回,开始处理信息
document.getElementById(currentPos).innerHTML = xmlHttp.responseText;
}
else
{ //页面不正常
alert("您所请求的页面有异常。");
}
}
}
function showRoles(obj,obj2)
{
currentPos = obj;
document.getElementById(obj).parentNode.style.display = "";
document.getElementById(obj).innerHTML = "正在读取数据..."
send_request("Server.aspx?phonenum="+document.getElementById(obj2).value+"&r" + Math.random());
}
</script>
<body>
<form action="#">
<select name="number" id="number">
<option value="888888">888888</option>
<option selected="selected" value="777777">777777</option>
</select>
<a href="#" onclick="showRoles('test','number')">立即查询</a>
<table>
<tr style="display:none ">
<td id="test" height="20"> </td>
</tr>
</table>
</form>
</body>
</html>
Server.aspx页面
<%@ Page Language="C#"%>
<script runat="server" type="text/C#">
protected void Page_Load(object sender,EventArgs e)
{
string phonenum =Convert.ToString(Request["phonenum"]);
Response.Write(phonenum + "|" + DateTime.Now.ToString());
}
</script>
这是我看别人的例子修改的,运行出来了,可以局部刷新页面。修改显示的时间。
- XMLHttpRequst对象的使用
- XMLHttpRequst对象
- 学习XMLHttpRequst对象
- 学习XMLHttpRequst对象
- 用XMLHttpRequst对象实现真实的网页加载进度
- 【AJAX好学易用系列】之二:XMLHttpRequst对象
- 函数对象的使用
- Request对象的使用
- 函数对象的使用
- Request对象的使用
- XMLHttpRequest 对象的使用
- cookie对象的使用
- AO对象的使用
- OutlookSession对象的使用
- GDI对象的使用
- ORACLE 对象的使用
- Intent对象的使用
- 函数对象的使用
- c#中通过自定义隐式转换实现返回值重载
- ASP.NET中水晶报表的使用
- Eclipse中debug程序
- 取得指定网页内容
- 侧栏广告
- XMLHttpRequst对象的使用
- ERP需求分析方法
- Office Operation
- Pattern Modifiers - 规则表达式的修饰符
- [转]FOR命令中有一些变量以及他们的用法
- WinForm中设计时与DesignMode的区别
- 加班mm一样可以“睡”出美丽肌肤
- 回复[ php有哪些好的书啊]
- 如何判断一个整数是不是一个大整数的因子