<html>
<head>
<script type="text/javascript">
var = xmlhttp;
function thumb(str)
{
xmlhttp = GetXmlHttpObject();
if (xmlhttp == null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="vote.php";
url=url+"?thumb="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=
stateChanged;
// Line cut in half because of Yahoo Answers text editor.
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("balance").
innerHTML=xmlhttp.responseText;
//Line cut in half because of Yahoo Answers text editor.
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// Code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// Code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>
</head>
<body>
<img src="thumbup.png" onclick="thumb(up);" />
<img src="thumbdown.png" onclick="thumb(down);" />
<span id="balance">?</span>
</body>
</html>
I have of course a file called vote.php that echoes a single number when given the variable ?thumb=up or ?thumb=down. To minimize mistakes, I copied this code form w3schools and then adapted it. But still I can't seem to make it work!
Your help would be much appreciated!
bump bump?
<head>
<script type="text/javascript">
var = xmlhttp;
function thumb(str)
{
xmlhttp = GetXmlHttpObject();
if (xmlhttp == null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="vote.php";
url=url+"?thumb="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=
stateChanged;
// Line cut in half because of Yahoo Answers text editor.
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("balance").
innerHTML=xmlhttp.responseText;
//Line cut in half because of Yahoo Answers text editor.
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// Code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// Code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>
</head>
<body>
<img src="thumbup.png" onclick="thumb(up);" />
<img src="thumbdown.png" onclick="thumb(down);" />
<span id="balance">?</span>
</body>
</html>
I have of course a file called vote.php that echoes a single number when given the variable ?thumb=up or ?thumb=down. To minimize mistakes, I copied this code form w3schools and then adapted it. But still I can't seem to make it work!
Your help would be much appreciated!
bump bump?