我有一个控制器可以返回这样的成功或错误页面:
[HttpPost]
public ActionResult File_post(HttpPostedFileBase file)
{
if (...)
return View("Success");
else
return View("Error");
}
这些成功和错误页面仅包含基本文本并显示在 Shared/_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,所以我想我需要用这个填充页面但是如何?
有任何想法吗 ?多谢 !