AJAX / HTTP问题 [英] AJAX/HTTP issue
问题描述
我有这个code的计算结果无论是否有标签,以确定哪些链接文字应该说一个链接:
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'}", '#', :id => 'edit_topics_link', :class => 'edit' %>
现在的问题是,我的标记系统完全更新与AJAX,而这个链接文字没有,所以它只是更新后,页面刷新正确的链接文字。我怎样才能让文字更新与AJAX?
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?
推荐答案
您可以做到这一点很容易地使用jQuery!
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的简单,不是吗?
Pretty simple, isn't it?
这篇关于AJAX / HTTP问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!