Jquery AjaxUpload 插件不会触发 onComplete 事件
我使用 Valums AjaxUpload 在 ASP.NET MVC 3 应用程序中上传文件。
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");
}
}
});
在我的控制器中,我有
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");
}
所以,我不明白返回“true”或“false”有什么区别......为什么我第一次看到结果,第二次看不到......需要你的帮助) )))
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))))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
呵呵,我明白了这个...
问题是在 ajaxupload.js 中“false”值有问题,所以需要将“false”更改为其他值!
所以,它完美运行!
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!!!