所以我在JSP的表格中有一个从mysql显示的电影及其信息列表。每部电影的表格条目都类似于<a id="135006" onmouseover=ajaxFunction(this); href=SearchSingleMovieServlet?txt_movie_id=135006>The Life Aquatic</a>
。
我的ajax功能如下:
<script language="javascript" type="text/javascript">
function ajaxFunction(obj){
var ajaxRequest;
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
$( '#'+ obj.id ).tooltip({
content: "<strong>Hi!</strong>",
track:true
});
document.getElementById('popup').innerHTML = '#' + obj.id+ ajaxRequest.responseText;
}
}
var parameter = "movie_id=" + obj.id;
ajaxRequest.open("POST","MoviePopUpWindowServlet", true);
ajaxRequest.setRequestHeader("Content-type"
, "application/x-www-form-urlencoded")
ajaxRequest.send(parameter);
}
</script>
行document.getElementById('popup').innerHTML = '#' + obj.id+ ajaxRequest.responseText;
只是一个调试行,所以我可以看到代码是否进入AJAX函数并确保responseText正确显示(它确实如此)。但是,当我尝试将鼠标悬停在电影的链接上时,它的工具提示并没有显示出来。有什么理由吗?