Ajax异步刷新
注意:
1、<div id="iframe">显示刷新的内容</div>
2、调用异步刷新:javascript:OnLink('地址')
<!--ajax异步刷新-->
<script type="text/javascript">
//创建XMLHttpRequestc对象
var xmlHttp=false;
//判断浏览器
function createXMLHttpRequest(){
if(window.ActiveXObject){//IE浏览器
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){}
}
}else{//其他浏览器:如mozilla 的 fireFox(火狐) 或者 netscape 7
xmlHttp=new XMLHttpRequest();
}
}
//提交获得值后的方法
function OnShow(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
var info=xmlHttp.responseText;
document.getElementById("iframe").innerHTML=info;
}
}
}
//要调用的方法
function OnLink(URL){
createXMLHttpRequest();
xmlHttp.open("post",URL,true);
xmlHttp.onreadystatechange=OnShow;
xmlHttp.send(null);
}
</script>
相关文档:
页面代码:
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManage ......
在《Pragmatic Ajax A Web 2.0 Primer 》中偶然看到对readyStae状态的介绍,感觉这个介绍很实在,摘译如下:
0: (Uninitialized) the send( ) method has not yet been invoked.
1: (Loading) the send( ) method has been invoked, request in progress.
2: (Loaded) the send( ) method has completed, entire respons ......
ASP.NET 2.0 Ajax中能够在客户端js中很方便地调用服务器Webservice,以下为一些调用的示例。笔者安装的ASP.NET 2.0 AJAX
版本为AJAX November CTP。
三个示例分别为:
1 带参数的WS方法
2 不带参数的WS方法
3 参数类型为DataTable的WS方法
一、WebMethod
注意要点:
1 WebMethod类需要添加命名空间 Microsoft.Web. ......
摘自:http://www.ibm.com/developerworks/library/wa-aj-jsonp1/
AJAX Same-Origin Policy(SOP) limitation:
AJAX prevents cross-domail invokation, there are several ways to by pass this limitation.
1. write a proxy on the server side. The SOP limitation only exists only on the javascript si ......
1、区块的显示与隐藏
在进行ajax编程时,经常会用到div标签对页面元素进行布局,大致方法是,把界面分做几大块,有时候需要根据点击菜单显示相应的块及隐藏其他块,这时可简单设置div.style.display为block进行显示,div.style.dispaly为none进行隐藏。
2、界面元素命名
&nb ......