62,074
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 从web服务器上下载文件
/// </summary>
/// <returns></returns>
public ActionResult DownFromDisk(string dataId)
{
try
{
if (dataId!="")
{
//这里有一些下载的代码
return new EmptyResult();
}
else
{
return Content("<script>alert('未找到文件ID!');</script>");
}
}
catch
{
return JavaScript("alert('数据下载时发生异常!');");
}
}
var script = String.Format("<script>alert('修改成功!');location.href='{0}'</script>", Url.Action("Index"));
return Content(script, "text/html");
2:return Content("<script>alert('添加失败!');</script>");
public ActionResult DoSomething(){
return Json(new {isok=true, message="Your Message", data=...});
//True / False Json Return
//return UserObj == null ?
//Json(true, JsonRequestBehavior.AllowGet) :
//Json(string.Format("YourObject '{0}' to String", YourObject),
//JsonRequestBehavior.AllowGet);
}
//view
$.ajax
{
//code
success :function(returnvalue)
{
if(!returnvalue.isok)
{
window.alert("Error:" + returnvalue.message);
}
else
{
//do the stuff with returnvalue.data
}
}