jquery simple ajax call (flag)

What's the best way to convert this:

<a href="#" onclick="saveFavorite('345', 'user@user.com');> Favorite</a>

To a clean/reusable ajax call with jquery?

13.10.2009 21:56:26
1 ОТВЕТ

not sure what you mean by convert...

you can always add id and class to your href like so you can reuse it accross app

<a id="345" class="addtofavorite" href="#" value="user@user.com">Favorite</a>

$(".addtofavorite").click(function(evt) {
  evt.preventDefault();
  var id = this.id;
  var value = this.value;
  saveFavorite(id,value);
});
0
14.10.2009 02:10:46