yas*_*ter 1 ajax ruby-on-rails response remotipart
我正在使用Remotipart上传文件.Rails-Controller处理文件,但我无法弄清楚如何获得以下ajax响应.这是我的js代码.
$file.children(".description").html(
'<%= form_for FileObject.new, :url => file_object_index_path , :html => { :multipart => true }, :remote => true do |f| %>' +
'<div class="field">' +
'<%= f.label :file %>' +
'<%= f.file_field :file %>'+
'</div>' +
'<input type="hidden" name="directory_object_id" value="' + current_directory.id +'" />' +
'<div class="actions">' +
'<%= f.submit %>' +
'</div>' +
'<% end %>'
);
$("form").bind('ajax:success', function(){
alert("success");
});
Run Code Online (Sandbox Code Playgroud)
也许有人之前已经解决过这个
ajax:success试试这个,而不是绑定到:
$("form").bind("ajax:complete", function(e, data, status, error){
if (data.status === 200 || data.status === 201) {
...
}
})
Run Code Online (Sandbox Code Playgroud)
在使用remotipart时我无法绑定ajax支持,并且过去曾使用过上述解决方法.