Jquery AjaxUpload plugin doesn't fire onComple

2019-09-04 14:10发布

I use Valums AjaxUpload for uploading file in my ASP.NET MVC 3 application .

new AjaxUpload($('input.partupload'), {
                autoSubmit: true,
                action: '/AdminPanel/Car/UploadPart',
                onSubmit: function (file, ext) {
                        if (!(ext && /^(zip)$/.test(ext.toLowerCase()))) 
                        {
                            $('#hinf').fadeIn('slow');
                            $('#hinf').html("Please, upload only Zip files!!");
                            return false;
                        } 
                    },
                data: { path: directoryPath,parentName : part, carId: @Model.carID, color: color },
                onComplete: function (file,response) {
                    var model = file.replace('.zip','');
                    if(response=="true")
                    {
                    alert(response);
                    createTree(part, model + '*' + part);
                    }
                    else
                    {
                    alert(response);
                    alert("Error during process");
                    }
                  }
            });

In my controller I have

 HttpPostedFileBase file = Request.Files[0];
            if (...)
{
    //Here my alert fires and onComplete is OK
    return Content("true");


}
else
{
               //FAIL!!! Nothing is happened in OnComplete!!!!!!
                return Content("false");
}

So, I don't understand what is difference to return "true" or "false"... Why I see result at first time, and don't see at second... Need in your help))))

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-04 14:33

Huh, I figure out this... Problem is that in ajaxupload.js something wrong with "false" value, so what neeeded is to change "false" to something other value!!!

So, it works perfectly!!!

 HttpPostedFileBase file = Request.Files[0];
            if (...)
{

    return Content("true");


}
else
{
     //WORKS!!!!
     return Content("error");
}
查看更多
登录 后发表回答