AJAX实现鼠标悬浮获取值
ajax实现将鼠标放到图标上,下方会显示和该图有关的信息
客户端代码mouseover.php
<!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>鼠标悬浮测试</title>
</head>
<script type="text/javascript" language="javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function sendRequest(t){
var id = t.id
createXMLHttpRequest();
var url = "mouseover_check.php?page=" +t.id ;
xmlHttp.onreadystatechange = callback;
xmlHttp.open('GET',url,true);
xmlHttp.send(null);
}
function callback(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
document.getElementById("show").innerHTML = xmlHttp.responseText;
}
}
}
</script>
<body>
<p>
<input type="text" value="here" id="1" onmouseover="sendRequest(this)" />
</p>
<p><br/>
<input type="text" value="haha" id="2" onmouseover="sendRequest(this)" />
</div>
</p>
<p></p>
<span id="show"></span>
</body>
</html>
服务器端代码:
mouseover_check.php
<?php
header("Content-type:text/html;charset=gb2312");
header("cache-control:no-cache,must-revalidate");
$name = $_GET['page'];
if($name == '1'){
echo "111";
}
else{
echo "222";
}
?>
相关文档:
1. 镜头迁徙应当应用实施镜头重定向的Response.Redirect而不是Server.Transfer,由于Server.Transfer不改变IE客户端URL,能以致ASP.NET AJAX客户端脚本访问资源的时分出现URL错处。
二.在服务器端登记脚本和掩藏字段应当施用种ScriptManager,而不是Page.ClientScript对象,由于Page.ClientScript的步骤是将脚本登记 ......
置顶:MOSS SP1开始支持AJAX。首先确认你的MOSS版本号
想必开发过MOSS AJAX控件的都知道,为了实现AJAX,必须对MOSS的环境进行大量的设置。网上有大量此类的文章,其中最流行的做法应该是刊登在moss开发团队blog上的(点击下面的URL进入)。
(http://blogs.msdn.com/sharepoint/archive/2007/03/02/integrating-asp-net- ......
AJAX实现二级级联菜单,用PHP完成,客户端代码:
<!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 ......
有关ajax的其实就是1个类的使用:XMLHttpRequest.
首先要声明这个类的对象,鉴于各个浏览器把这个类嵌入的方式不同,声明的方式也不同:
var xmlHttpReq = null;
if (window.XMLHttpRequest) //Mozilla 浏览器
{
xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) // ......