天天看點

ajax滑鼠懸停,利用AJAX實作滑鼠懸浮擷取值的代碼

用戶端代碼mouseover.php

滑鼠懸浮測試

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;

}

}

}