I have a page below with buttons and a div pageContent to host my partial views
div id="ProjID">
<div id="pjls">
<label for="SelectProjID">Project:</label>
</div>
</div>
<button class="links" data-url='@Url.Action("link1method","Home")'>Link1</button>
<button class="links" data-url='@Url.Action("link2method","Home")'>Link2</button>
<button class="links" data-url='@Url.Action("link3method","Home")'>Link3</button>
<div id="pageContent"></div>
I have this jquery that is used to load the partial views and their content
$('.links').on('click', function (e) {
e.preventDefault();
var $pageContent = $('#pageContent');
url = $(this).data('url');
$.get(url, function (data) {
$pageContent.replaceWith(data);
});
})
Below is what my controller methods look like
public ActionResult link1method(string sample)
{
return PartialView("_Partial1");
}
public ActionResult link2method(string sample)
{
return PartialView("_Partial2");
}
public ActionResult link3method(string sample)
{
return PartialView("_Partial3");
}
At the moment when you click the Links button, it is only Link1 that loads the partial view others do not work. when you click on buttons 2 and 3 nothing happens. What am I doing wrong? I will also like to pass a parameter to each controller method.