开发者

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 cl开发者_开发知识库ean/reusable ajax call with jquery?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜