开发者

AJAX/HTTP issue

I have this code for a link that evaluates whether or not there are tags to determine what the link text should say:

<%= link_to "#{(@video.topics.count == 0) ? 'Add descriptive topics so people can find your song!' : 'Edit Topics开发者_C百科'}", '#', :id => 'edit_topics_link', :class => 'edit' %>

The problem is that my tagging system updates completely with AJAX, and this link text does not, so it is only updated to the correct link text after a page refresh. How can I make the text update with AJAX?


You can do this easily using jQuery!

Just fetch the update data from the server (using $.get or $.post) and then update the link using the text() function. Here's an example:

$.get('http://some.url',{},function(response) {
  $('#edit_topics_link').text(response);
}

Pretty simple, isn't it?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜