Answer the question
In order to leave comments, you need to log in
Link_to, ajax and post request?
Hello Habr!
For an hour I can not solve the problem. Help me please. And here's the problem. There is some link that needs to get the form from the Ajax server. But in response to the request, 404 comes out. The link code itself is as follows
= link_to "Редактировать", controller: "navigation", action: "form_for_new_item", remote: true, method: :post
post '/navigation/form' => 'navigation#form_for_new_item'
def form_for_new_item
@item = Navigations.new
respond_to do |format|
format.js
end
end
<% @item.drop_down = false %>
var form = document.createElement('div')
$(form).append('<%= form_for @item, url: { action: "create_item"} do |form| %>
<%= form.text_field :name %>
<%= form.text_field :url %>
<%= form.text_field :sort_id %>
<%= form.submite "Создать" %>
<%end%>
')
$(form).dialog("open")
GET http://0.0.0.0:3000/navigation/form<b>?method=post (???)</b> 404 (Not Found) jquery.js?body=1:9667
send jquery.js?body=1:9667
jQuery.extend.ajax jquery.js?body=1:9212
$.rails.rails.ajax jquery_ujs.js?body=1:81
$.rails.rails.handleRemote jquery_ujs.js?body=1:157
(anonymous function) jquery_ujs.js?body=1:307
jQuery.event.dispatch jquery.js?body=1:4625
elemData.handle
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question