Handling Jsonp In Rails 3 Controller
I want my controller action to handle jsonp requests from jquery $.getJSON. In my controller action i have the following respond_to block: respond_to do |format| format.html { re
Solution 1:
respond_to do |format|
format.html { render json: {:items_by_tag => @tagged_item_list}}
if params[:callback]
format.js { render :json => {:items_by_tag => @tagged_item_list.to_json}, :callback => params[:callback] }
else
format.json { render json: {:items_by_tag => @tagged_item_list}}
end
end
Post a Comment for "Handling Jsonp In Rails 3 Controller"