Hello.

I'm working on a simple thumbs up/down functionality with javascript
(jquery). I have list of entries which can be rated up or down and
this has to be done with ajax.

I came to a design consideration problem as I dont have many
experience with javascript programming:

How should I process all links inside a html file so that it would set
onClick event on links and this would call a function that would
preform certain http request.

Should I give each link an unique id e.g. "rating12" and then set
onclick action for each of the elements so that it would look
something like:

<script>
$(document).ready(function() {
 $("a#rate1").click(function () { //ajax call });
}); </script>
<a id="rate1" href="#" class="rate up">rate up</a>

<script>
$(document).ready(function() {
 $("a#rate2").click(function () { //ajax call });
}); </script>
<a id="rate2" href="#" class="rate up">rate up</a>

etc..

or would it be better to make jquery find each class 'rate' and read a
href from each (with one block code) so that also users with no
javascript could face normal functionality (without ajax) or is there
any better solution/approach for this?

Whats the best way to deal with this?

Many thanks in advance!

Reply via email to