NameSilo

AJAX/Javascript help

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back