Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RemotipPart获得ajax响应_Ruby On Rails_Ajax_Response_Remotipart - Fatal编程技术网

Ruby on rails RemotipPart获得ajax响应

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| %>' + '

我正在使用Remotipart上载文件。Rails控制器处理该文件,但我不知道如何获得以下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");
});
$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。请参阅我对如何更优雅地解决此问题的类似问题的回答: