开发者

Jquery AjaxUpload plugin doesn't fire onComplete event

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(开发者_如何学JAVA'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))))


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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜