在Rails中使用jQuery的Ajax请求
我正在使用jQuery发送一个Ajax请求。发生的情况是,我得到了一个405方法不允许的错误。我只是发布一个表单,它将从表单中获取详细信息并将其插入DB。我使用的是WEBrick,它是rails包的默认值。谁能告诉我怎么修理这个吗 这是触发Ajax请求的代码 $.post$this.attraction+.js,$this.serialize,null,script在Rails中使用jQuery的Ajax请求,jquery,ruby-on-rails,ajax,webrick,Jquery,Ruby On Rails,Ajax,Webrick,我正在使用jQuery发送一个Ajax请求。发生的情况是,我得到了一个405方法不允许的错误。我只是发布一个表单,它将从表单中获取详细信息并将其插入DB。我使用的是WEBrick,它是rails包的默认值。谁能告诉我怎么修理这个吗 这是触发Ajax请求的代码 $.post$this.attraction+.js,$this.serialize,null,script Response Headers Cache-Control no-cache Allow GET, PUT, DELET
Response Headers
Cache-Control no-cache
Allow GET, PUT, DELETE
Content-Type text/html; charset=utf-8
Content-Length 9502
Server WEBrick/1.3.1 (Ruby/1.9.1/2009-12-07)
Date Wed, 02 Jun 2010 20:41:33 GMT
Connection Keep-Alive
Request Headers
Host localhost:3000
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept application/json, text/javascript, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Content-Type application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With XMLHttpRequest
Referer http://localhost:3000/viewspot/3
Content-Length 141
Pragma no-cache
Cache-Control no-cache
为什么要使用非restful url创建注释?是否可以使用rest提供的正常创建操作?我真的很推荐你,这会让你的想法更容易 如果您能做到这一点,那么此form_for方法应该可以做到:
<% form_for Comment.new do |f| %>
我知道这是同一原产地政策的错误。
看起来您调用了错误的url。。你能粘贴你的表单吗?{:action=>add_comment},:html=>{:id=>add_comment,:method=>:post}do | f |%>