本文介绍了当基于html5的文件上传成功时,如何在mvc3中获得响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望成功上传文件时显示响应值...
我的代码是......
I want display response value when file is uploaded succesfuly...
my code is ...
<form class="form1" enctype="multipart/form-data" method="post" action="@Url.Action("Upload")" >
<input id="fileToUpload1" name="fileToUpload1" type="file"/>
<div style="width:500px;">
<div id="Mydiv"></div>
<progress id="progressBar" value="0" max="100"> </progress>
</div>
</form>
<script type="text/javascript">
// File load event
xhr.upload.addEventListener("load", loadSuccess, false);
function loadSuccess(evt) {
//here i want to display response result
// alert("Response");
}
控制器是...
controller is...
[HttpPost]
public ActionResult Upload(object fileToUpload1)
{
int sucessid= 101;
return Json(sucessid, JsonRequestBehavior.AllowGet);
}
和我希望在上传成功事件中显示的成功ID ...控制器返回该值但不显示在警报中加载事件处理程序方法...
and that succes id i want to display on upload success event of view...Controller return that value but not display in alert of load event handler method...
推荐答案
这篇关于当基于html5的文件上传成功时,如何在mvc3中获得响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!