I have a page with a sidebar menu . On clicking the side bar menu I expand a jstree . On clicking any of the nodes of this tree the partial page on the main page should reload . However this does not seem to be happening .
Simplified MainPage.html
<body class="claro">
<div id="header">
<div id="logindisplay">
@Html.Partial("_LogOnPartial")
</div>
</div>
<div id="menucontainer2">
@Html.Partial("_SideLayout")
</div>
<div id="main">
@RenderBody()
</div>
</body>
I create a sidebar layout in the form of a jstree view ( which renders fine ) and wait for the use to click on the tree nodes . ie.
SideBarLayout.html
<div id="divtree">
<ul id="tree">
<li>
Manage Profile
</li>
<li ><a>Settings</a>
<ul>
<li><a>Configuration Settings</a>
<ul>
<li><a>Customer Setup</a></li>
<li><a>Job Setup</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
script type="text/javascript">
$(function () {
$("#divtree").jstree();
$("#divtree").bind(
"select_node.jstree", function (evt, data) {
debugger;
var url = '@Url.Action("Index", "Order", new{ Area = "OrderModule"})'; -----> is this correct way to call the MVC 4 Controller ?
console.log(url);
$.post(url, function (data, status) {
alert("Data: " );
});
}
);
});
</script>
1 . As you can see currently I am creating the same url irrespective of which node of the tree is clicked . Once i can update my partial view on the MainPage.html I shall take care of this .
2 .
the _LogOnPartial works fine and is able to update the partial view of the mainpage correctly . It simply contains something like this
@Html.ActionLink("Log Off", "LogOff", "Account")
However I am unable to manipulate the jstree to update the partial view . Can anyone help me with the correct jquery command to call the MVC 4 controller so that my page updates?
**EDIT**
I am now able to get the connect to POST the data to the server ( My alert says success ). However still my partial view in the main page is not rendered
. Correct Ajax Call :
$.ajax({
url: '@Url.Action("Index", "DpcmOrder", new { area = "AmethystWorkestraModule" })',
type: 'POST',
cache: false,
async: false,
data: $('form').serialize(),
success: function (data) {
//your ajax data
alert('success');
$('#main').html(data);
},
error: function (e) {
alert('fail');
console.log(e);
}
});