嗨我的应用程序中有多个具有相同结构的元素.第二个div元素的id根据db中唯一的注释id而变化.有些元素的id为’Vote_up’和’Vote_down’.每个评论都会重复这一点.正如我所提到的那样,会发生多条评论.我想执行Ajax请求.第一个结构使用ajax正常运行,但其余部分执行http请求.顺便说一句我正在开发一个rails应用程序,我正在使用jQuery.
<div id="post_comment">
john<i> says </i> Comment<br/>
<div id="comment_10_div">
**<form action="/comments/Vote_up" id="Vote_up" method="post">**
<div style="margin:0;padding:0;display:inline">
<input name="authenticity_token" type="hidden"
value="w873BgYHLxQmadUalzMRUC+1ql4AtP3U7f78dT8x9ho=" />
</div>
<input id="Comment_place_id" name="Comment[post_id]" type="hidden" value="3" />
<input id="Comment_id" name="Comment[id]" type="hidden" value="10" />
<input id="Comment_user_id" name="Comment[user_id]" type="hidden" value="2" />
<input name="commit" type="submit" value="Vote up" />
</form>
<label id="comment_10">10</label>
**<form action="/comments/Vote_down" id="Vote_down" method="post">**
<div style="margin:0;padding:0;display:inline">
<input name="authenticity_token" type="hidden"
value="w873BgYHLxQmadUalzMRUC+1ql4AtP3U7f78dT8x9ho=" />
</div>
<input id="Comment_place_id" name="Comment[place_id]" type="hidden" value="3" />
<input id="Comment_id" name="Comment[id]" type="hidden" value="10" />
<input id="Comment_user_id" name="Comment[user_id]" type="hidden" value="2" />
<input name="commit" type="submit" value="Vote Down" />
</form>
</div>
你能帮我解决一下吗?
谢谢
解决方法:
是的,正如Matti上面提到的,W3C标准ID必须是唯一的.一个很好的解决方法是postfix comment的db ID,例如< input id =“Comment_39127438”......
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。