NameSilo

AJAX/Javascript help

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

iNod

Eating PieVIP Member
Impact
66
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
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
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back