Javascript 如何从json中的路由转换res,而不是从回调函数转换数组?

Javascript 如何从json中的路由转换res,而不是从回调函数转换数组?,javascript,arrays,json,node.js,ajax,Javascript,Arrays,Json,Node.js,Ajax,我使用ffmpeg从视频中提取帧,因为它的回调函数返回阵列中提取帧的路径 但是,这种反应并没有传回ajax的成功。它仅显示在同一路径上,可能是因为我发送的响应是数组形式的 在这方面需要帮助 代码--- --Ajax代码--- $('send#u file')。提交(函数(e){ e、 预防默认值(); var video_file=$('#video upl').val(); var profilehtml=''; $(此).ajaxSubmit ({ 数据:{videofile:video_f

我使用ffmpeg从视频中提取帧,因为它的回调函数返回阵列中提取帧的路径

但是,这种反应并没有传回ajax的成功。它仅显示在同一路径上,可能是因为我发送的响应是数组形式的

在这方面需要帮助

代码---

--Ajax代码---

$('send#u file')。提交(函数(e){
e、 预防默认值();
var video_file=$('#video upl').val();
var profilehtml='';
$(此).ajaxSubmit
({
数据:{videofile:video_file},
数据类型:“JSON”,
contentType:'应用程序/json',
成功:功能(响应){

对于(i=0;i这是什么意思:
它仅显示在同一路线上
?当我上传视频时,它移动到/upload路线,当我发送res.send(filepath)等响应时它打印在index.html/upload而不是index.htmly上。您没有处理API中的错误。如果API抛出错误,您也需要发送到客户端。我已经编写了console.log来处理错误,如您所见。。。
app.post('/upload',app.upload.single('video-upl'),function(req,res){

    var video_file = fs.createReadStream(req.file.path); // Storing File path
    var video_String = JSON.stringify(video_file); // Converting Json into String of req.file.path
    var video_res = JSON.parse(video_String); // Parsing req.file.path  

    var valueArray = tosplit(video_res.path);  //Splitting Path in values

    var filenme = req.file.originalname; // Requesting Original File name
    var filnameStringify = JSON.stringify(filenme); //Stringify file original name
    var filnameParse = JSON.parse(filnameStringify); //Parsing file Original name

    var filename = extsplit(filnameParse);  // Spliting File name from path

    var finalpath = './public/class/'+valueArray[2]; // Path to Video for Extracting Images

    var destpath = './public/class/'+filename[0]+'/'; //Destinaton Path to Store Images

    var zipdest = './public/class/'+filename[0]; //Destination of File to be Zip

    var articleid = extsplit(valueArray[2]);  //For ArticleId through Video Name

    try {
    var process = new ffmpeg(finalpath);
    process.then(function (video) {
        // Callback mode
        video.fnExtractFrameToJPG(destpath, {
            frame_rate: 1,
            number: 50,
            keep_pixel_aspect_ratio : true,
            keep_aspect_ratio: true,
            file_name : filename[0]+'_%s'
        }, function (error,files){

            if(!error)
                {   
                    var fileJsonStr = JSON.stringify(files);

                    makeZip(zipdest,'./public/class/'+filename[0]+'.zip');

                    console.log(res);

                    res.send(fileJsonStr);
                }
        });
    }, function (err) {
         console.log('Error: ' + err);
    });
  }

    catch (e) {
    console.log(e.code);
    console.log(e.msg);
}
});
 $('#send_file').submit(function(e){
        e.preventDefault();

        var video_file = $('#video-upl').val();
        var profilehtml = '';


        $(this).ajaxSubmit
        ({
            data: {videofile : video_file},
            datatype: 'JSON',
            contentType: 'application/json',
            success: function(response){
                for(i=0;i<=response.length;i++)
                    {
                        profilehtml += '<tr>';
                        profilehtml += '<td>'+response[i]+'</td>';
                        profilehtml += '</tr>';
                    }
                    $("#img-bind").html(profilehtml);
            }
   });
});