我想在post方法上使用ajax而不是整個視圖加載div數據。 ,但是它會在操作後返回object%20HTMLInputElement
操作名稱。Ajax.BeginForm在mvc中呈現錯誤的URL
控制器:
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(DemoCLass objdemo)
{
return View();
}
查看
<div id="divEmp">
@using (Ajax.BeginForm("Index", "Challan", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divEmp" }))
{
@Html.AntiForgeryToken()
<h3 style="text-align:center;" class="row header">Challan Data</h3>
@Html.Partial("_DateCommonFT")
}
它包括_Layout.cshtml
在那裏我有定義的腳本爲:
<script src="~/Scripts/jquery-1.12.4.min.js"></script>
<script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
如何只呈現發佈ction不需要在使用ajax的post請求中加載整個頁面(_layout.cshtml)。
對不起!你面臨的問題是什麼?我仍然無法理解您當前和預期的行爲。 – Shyju
關閉你的div標籤,如
– hasan@Priya更新你的問題與錯誤消息/意外的行爲和預期的輸出。 –