I am trying to write an AJAX script that will display IMDb rating when I mouse over text. It works but it only displays the rating on the first result due to it being the first span tag it finds.
Here is the page: http://www.bobtownmctchargeumc.org/com/index.php
Hover over "Rating:"
Here is the JS
var url = "server_script.php?title="; // The server-side script
function handleHttpResponse() {
if (http.readyState == 4) {
if(http.status==200) {
var results=http.responseText;
document.getElementById('imdbrating').innerHTML = results;
//alert(results);
}
}
}
function getimdbrating(title) {
//var sId = document.getElementById("ajax_res").value;
http.open("GET", url + title, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function getHTTPObject() {
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (!xmlhttp){
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
Here is the html.
<span onmouseover=\"getimdbrating('".$movRows['imdb']."');return false;\">Rating: </span> <span id='imdbrating'></span>
I want the rating to display next to the movie.