我有一个控制器谁可以返回一个成功或错误页面是这样的:jQuery和剃刀控制器视图的ActionResult
[HttpPost]
public ActionResult File_post(HttpPostedFileBase file)
{
if (...)
return View("Success");
else
return View("Error");
}
那些成功和错误页面只包含基本的文本并显示在共享/ _Layout.cshtml 。
在我的JS我想调用返回视图定义的那些页面,但我怎么能做到这一点?
我测试过:window.location.reload();
虽然有效,但它只能重新加载实际的索引页面。
如果我尝试:window.location.href = data.url;
由于页面http:// xxx/xxx/File_post不存在,所以失败。
如果我这样做:$('#main').html(data);
页面有好看但内容是空的。
编辑:我使用jquery.fileupload所以我有:
<input id="fileupload" type="file" name="file" />
和
$('#fileupload').fileupload(
{
done: function (e, data) {
// Use the return View("Success")
},
fail: function (e, data) {
// Use the return View("Error")
}
});
在我jqXHR.reponseText和data.result有良好的 “成功” 或“错误”的HTML,所以我想我需要填写这个页面,但如何?
任何想法?非常感谢 !
File_post不是ajax调用,还是它?什么时候完成调用?这就是我有点困惑的地方。 –