I have an jquery AJAX call that loads a window. In the window, there is a form with a submit to allow the users to download an item. I have to make this second form use a regular submit so that I can prompt a download.
My problem is when there is no file to download, it redirects to the page in which this file is located.
I am trying many different styles of getting it to render nothing, but none of them seem to work.
unless params[:controller] == "reports"
unless @jobs.present?
flash.now[:error] = "No work orders for this selection."
render :nothing => true
end
end
Also
respond_to do |format|
format.html { render :nothing => true }
end
Nothing seems to work. Any ideas?
Don't use render: nothing.
This will "fail" ajax request.
Instead, use:
render json: nil, status: :ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With