0
我用Ajax.BeginForm
表單發帖。Asp.net mvc ajax多跑一次
但是當我快速點擊按鈕不止一個。處理工作不止一個。 RefreshPosts();
腳本工作時,會重置表單元素。
控制器:
public string SharePost(FormCollection form)
{
var singleUser = _repUsers.GetUserWithCookie(GetCookie(_set.userCookieName));
string content = Request.Form["statusText"];
_opPosts.AddPost(content, singleUser.UserId);
_opUsers.AddFeed(1, singleUser.UserFirstName, singleUser.UserSurName);
Session["PostDate"] = DateTime.Now;
return "Başarıyla paylaştık." + "<script> refreshPosts(); </script>";
}
查看:
@using (Ajax.BeginForm("SharePost", "Post", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "result", OnSuccess = "postSuccess", LoadingElementId = "loading" }))