rails下一般的HTTP请求与AJAX请求如何区别?
我想区别一下如何区分一般的HTTP请求与AJAX请求。
[code="ruby"]
if request.get?
elsif request.post?
elsif request.xhr?
[/code]
request.xhr?
可以通过
respond_to do |format|
format.html { redirect_to(blog_path(params[:comment][:blog_id])) }
format.xml { render :xml => @comment, :status => :created, :location => @comment }
format.js
end
来划分不同的反映
少了个[color=red]end[/color]