I have this controller:
public ActionResult Index()
{
return View();
}
[HttpGet]
public PartialViewResult Code()
{
return PartialView("Code");
}
[HttpPost]
public PartialViewResult Code(string code)
{
return PartialView("Code");
}
I have call partial in my Index view
@Html.Partial("Code")
and here's my partial view
@model Kubeti.Models.Codes
@using (Ajax.BeginForm(new AjaxOptions { HttpMethod="POST", UpdateTargetId = "result", InsertionMode=InsertionMode.Replace }))
{
@Html.EditorFor(x => x.code)
@Html.ValidationMessageFor(x => x.code)
<input type="submit" value="OK" />
}
<div id="result" style="width: 500px; height:500px; border:1px solid red;">
</div>
Of course I have jquery and unobtrusive.js in my Layout
@RenderBody()
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
But when I'm clicking on submit it goes in my index action (I'm debugging) instead of my PartialViewResult Code. What's wrong with it?
In console there's this warning:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
I google it but can't find answer which will customize to my problem..