| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Eating Pie Join Date: Nov 2004 Location: Canada
Posts: 2,272
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | AJAX/Javascript help 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,rateimageidgoestherewit hphp)" id="rating_1">Stuff</a> ????: NamePros.com http://www.namepros.com/programming/231612-ajax-javascript-help.html ... ... ... 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 = '';
} 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 feel old. |
| |