Hey,
I am trying to get this thing to work. But it doesn't.. Anyways enough n00bie stuff.. So.. Basically it used XMLHttpRequest to 'get' / 'post' a rate image id and a rating to rate.php. In the format of rate.php?r=votevalue&i=rateimageid.. I have the html side all done and I know it works.
Basically just
<a href="javascript:sendReq(1,rateimageidgoestherewithphp)" id="rating_1">Stuff</a>
...
...
... etc for 5 of them.. Each using the CSS rate image thingy.
The AJAX/Javascript code is this
Myself not being that great at the old javascript just did what I know.
But for some reason.. When you click on it.. It is just not working.. The rate.php works because I tested that.. It is just this AJAX part..
Any help will be apprecited.
- Steve
I am trying to get this thing to work. But it doesn't.. Anyways enough n00bie stuff.. So.. Basically it used XMLHttpRequest to 'get' / 'post' a rate image id and a rating to rate.php. In the format of rate.php?r=votevalue&i=rateimageid.. I have the html side all done and I know it works.
Basically just
<a href="javascript:sendReq(1,rateimageidgoestherewithphp)" id="rating_1">Stuff</a>
...
...
... etc for 5 of them.. Each using the CSS rate image thingy.
The AJAX/Javascript code is this
Code:
function sendReq(vote,id_num) {
/* Set up the request */
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('get', 'rate.php?r='+vote+'&i='+id_num);
/* The callback function */
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200)
addRatingFeedback(xmlhttp.responseXML, target);
}
}
xmlhttp.send(null);
}
function addRatingFeedback(responseXML, target) {
var width = responseXML.getElementsByTagName('rating')[0].firstChild.data;
document.getElementById('current_rating')style.width = width;
document.getElementById('rating_1')href = '';
document.getElementById('rating_2')href = '';
document.getElementById('rating_3')href = '';
document.getElementById('rating_4')href = '';
document.getElementById('rating_5')href = '';
}
Myself not being that great at the old javascript just did what I know.
But for some reason.. When you click on it.. It is just not working.. The rate.php works because I tested that.. It is just this AJAX part..
Any help will be apprecited.
- Steve






