Hi,
@using (Ajax.BeginForm("CalculateWithAjaxJsonBeginForm", "Home", new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "SuccessMessage", // JS
OnFailure = "FailMessage", // JS
UpdateTargetId = "result" // p tag ID
}, new {@id = "myForm" }))
{
@Html.TextBox("num1", null, new { @type = "number" })
@Html.TextBox("num2", null, new { @type = "number" })<input type="submit" value="Submit form with ajax" id="btnSubmit" /><p id="result"></p>
} [HttpPost]
public ActionResult CalculateWithAjaxJsonBeginForm(int num1, int num2)
{
ViewBag.Result = num1 + num2;
int responseText = num1 + num2;
// return Json(new { success = true, responseText = num1 + num2 }, JsonRequestBehavior.AllowGet);
return Json(responseText, JsonRequestBehavior.AllowGet);
}I have this code which manage to come to the controller. But it does not return back to the view. Any idea what went wrong?