Handling jsonp in rails 3 controller

前端 未结 1 1264
庸人自扰
庸人自扰 2020-12-16 05:07

I want my controller action to handle jsonp requests from jquery $.getJSON. In my controller action i have the following respond_to block:

respo         


        
相关标签:
1条回答
  • 2020-12-16 05:08
    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
    
    0 讨论(0)
提交回复
热议问题