Suppose I have a number of red colored links, and want to add a click event to them such that when it fires, it sends HREF attribute of link to server (as an AJAX request), and on success, the link color will be changed to green. I want something like:
$$('a.red').addEvent(
"click",
function () {
new Request.JSON({
url: 'script.php',
onSuccess: function(){
[the link wich is clicked].setStyle('color', 'green');
return false;
}
}).get("url="+[url of the link]);
}
);
Sorry if silly question. please edit title to some sensible one.