I Have HTML Page "Index.cshtml"
<div class="container" >
<div class="row">
<div class="col-md-6" id="employeeList">
@Html.Partial("IndexPartial");
</div>
<div id="second">
other div
</div>
<button onclick="Increase()">increase</button>
</div>
</div>
partial view which contains employee table, button which clicked calls JS Script which executes controller method increasing employee age
<script>
function Increase(id) {
$.ajax({
url: 'Main/Increase',
data: { id: 5 },
UpdateTargetId:"employeeList",
success: function () {
alert('Added');
}
});
}
</script>
I ran firebug and it shows that each button click returns html response with updated employee Table (employee age is updated) but in browser there are still old values until I manually refresh page
You seem a bit confused. Let's go over a few things.
Partial is a built-in method that renders a view to a string (an IHtmlString). This runs once when the page is being constructed.
$.ajax()
is a jQuery function. This function (as far as I can recall) does not accept a property called UpdateTargetId
. I think you've confused that with the .NET AjaxOptions class which does accept an option called UpdateTargetId.
One way to quickly get things working is to change your success function to take a data
argument and then insert the HTML into the div.
success: function (data, textStatus, xhr) { }
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments