Reputation: 107
My ajax is not enabled.
When I press on an ajax Link, the page posts to a partial page.
What is wrong in my code ?
I am using Visual Studio 2013 express MVC4
View
@{
ViewBag.Title = "Home Page";
}
@Ajax.ActionLink("link", "Test", new AjaxOptions {
HttpMethod="POST",
UpdateTargetId="t",
InsertionMode=InsertionMode.Replace
})
<div id="t">mmmmmmmmmmmmmmmmmm</div>
Controller
public PartialViewResult Test ()
{
return PartialView("_PTest");
}
public ActionResult Index()
{
return View();
}
Partial View
<p>partial test</p>
_LayOut
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
Upvotes: 1
Views: 2247
Reputation: 1520
You need to ensure Unobtrusive Ajax is referenced. It should be present at the point of creating a new MVC project but if you need details to get it from Nuget, take a look here https://www.nuget.org/packages/jQuery.Ajax.Unobtrusive/
Upvotes: 3