everyone. I am using NET Framework 4.8.1. I'm having a problem when I try to reload a view, it's like it doesn't delete my javascript and going to reload it sends all the constants to me in error.
I attach the code below.
HTML:
<div class="row bg-dark">
<div class="col-2" style="margin-top: 1%;">
<div class="row">
<div class="row">
<h2>Menu</h2>
</div>
<hr>
<div class="row">
<ul class="nav nav-pills flex-column mb-auto">
<li>
<a onclick="LoadComponents()" id="btnDashboard" class="nav-link text-white active">
Dashboard
</a>
</li>
<li>
<a href="#" id="btnNotification" class="nav-link text-white position-relative">
Notification <span id="spanCount" style="color: red;"></span>
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
Logout
</a>
</li>
</ul>
</div>
<hr>
</div>
</div>
<div class="col-10" style="margin-top: 1%;" id="divLoadComponent">
</div>
</div>
Js:
function LoadComponents(){
$('#divLoadComponent').empty()
var url = '@Url.Action("Accounts", "Home")'
$('#divLoadComponent').load(url)
}
It behaves as if the script is not deleted with $('#divLoadComponent').empty()
and as a result I reload all the html with the script each time and the constants fail, in addition to the fact that the alerts are repeated for each time I click on "Dashboard".