In ASP.NET MVC 3 application I use Ajax.BeginForm to post writed text to controller.
@using (Ajax.BeginForm("Post", "Forum", new {threadId = Model.Thread.Id }, new AjaxOptions { OnSuccess = "PostReply" }))
{
<div id="reply-area">
<h3 style="border-bottom:1px solid black">POST REPLY</h3>
<span id="post-error" class="error-message"></span>
<textarea rows="1" cols="1" id="post-textarea" name="Content"> </textarea>
<input type="submit" class="button" value="Submit"/>
</div>
}
In controller I have
[HttpPost]
public ActionResult Post(int threadId,PostModel model)
{
bool Success = false;
if (ModelState.IsValid)
{
Success=Unit.ForumFacade.CreatePost(Unit.ForumFacade.GetThreadByID(threadId), model.Content, CurrentUserId);
if (Success == true) return View("PostSuccess");
}
return Json("fsdfds");
}
And in javascript I have this
function PostReply(isRequestSuccessed) {
alert("asdasd");
if (isRequestSuccessed==false) {
$("#post-error").html("Please Try Again");
}
else
{
$("#post-error").html("");
}
}
The problem is that Javascript's function doesn't firing and isntead the alert, my browser(Firefox) returns me pop-up to download application/json file. What is wrong here?