I have runned in to a strange issue. I wont to load an xml file and parse it via ajax, and append its contents to display on a page for further approval.
In view I have:
<%= form_tag import_path, multipart: true, remote: true do %>
<%= file_field_tag :file %>
<%= submit_tag "load" %>
<% end %>
controller:
respond_to :js
def import
respond_to do |format|
parsing stuff ....
@result = parsed_corrections
format.js {render "import"}
end
end
Also I have import.js.erb view, with just alert for testing. When I submit an empty form it works correct(content type is text/javascript), but if I submit an xml file it shows "Completed 406 Not Acceptable" content type is text/html.
I guess that issue is with content type. jquery_rails and jquery_ujs are included in layout.
Thanks in advice for help.
U need to handle xml format
respond_to do |format|
format.html
format.xml { parsing stuff.. }
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.