Ruby on rails RemotipPart获得ajax响应
我正在使用Remotipart上载文件。Rails控制器处理该文件,但我不知道如何获得以下ajax响应。这是我的js代码Ruby on rails RemotipPart获得ajax响应,ruby-on-rails,ajax,response,remotipart,Ruby On Rails,Ajax,Response,Remotipart,我正在使用Remotipart上载文件。Rails控制器处理该文件,但我不知道如何获得以下ajax响应。这是我的js代码 $file.children(".description").html( '<%= form_for FileObject.new, :url => file_object_index_path , :html => { :multipart => true }, :remote => true do |f| %>' + '
$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");
});
$file.children(“.description”).html(
'file_object_index_path,:html=>{:multipart=>true},:remote=>true do | f |%>'+
'' +
'' +
''+
'' +
'' +
'' +
'' +
'' +
''
);
$(“form”).bind('ajax:success',function(){
警惕(“成功”);
});
也许有人以前解决过这个问题 不要绑定到
ajax:success
,尝试以下操作:
$("form").bind("ajax:complete", function(e, data, status, error){
if (data.status === 200 || data.status === 201) {
...
}
})
我在使用remotipart时绑定ajax支持时遇到问题,并且在过去使用过上述解决方法。请尝试以下方法,而不是绑定到
ajax:success
:
$("form").bind("ajax:complete", function(e, data, status, error){
if (data.status === 200 || data.status === 201) {
...
}
})
我在使用remotipart时绑定ajax支持时遇到问题,并且在过去使用过上述解决方法。可能是您的响应是HTML,而不是默认情况下预期的JS remotipart。请参阅我对如何更优雅地解决此问题的类似问题的回答:可能是您的响应是HTML,而不是默认情况下预期的JS RemotipPart。请参阅我对如何更优雅地解决此问题的类似问题的回答: