I have an user table. When I want to edit my user's infos, I want to open the update page as a popup. Right now I can open the popup but when I try to call HttpGet update method to get user's infos, it's not working. What am I missing here?
My update button to open the popup
<button data-id="@obj.Id" type="button" class="classExample" onclick="onUpdateButtonClicked(@obj.Id)" data-toggle="modal"> update </button>
My Popup
<div id="updateModal" class="modal"> //My Update fiels will be here </div>
My Js code
const modal = document.querySelector("#updateModal") const spans = document.querySelectorAll('.close'); const cancelBtns = document.querySelectorAll(".cmsBtnCancel") window.onclick = function (event) { if (event.target == modal) { modal.style.display = "none"; } } spans.forEach(span => { span.addEventListener('click', () => { modal.style.display = "none"; }) }) cancelBtns.forEach(cancelBtn => { cancelBtn.onclick = () => { modal.style.display = "none"; } }) const onUpdateButtonClicked = function (id) { var deleteInput = document.getElementById('delete-input'); //modal.style.display = "block"; if (id == undefined) { deleteInput.value = this.dataset.id; } else { deleteInput.value = id } $.ajax( { type: "GET", page: 1, rp: 6, url: '@Url.Action("Update","User")' + "?id=" + id, dataType: "json", success: function (result) { modal.style.display = "block"; }, error: function (x, e) { } }); };
.js
file instead of on the view..js
files don't process server-side code like views do.