Answered by:
Error

Question
-
User1979860870 posted
Hi
I am getting below error - HR is Id value. When i click on Delete this error occurs
Uncaught ReferenceError: HR is not defined at HTMLAnchorElement.onclick (Location:1)
function loadData() {
$.ajax({
url: "/Location/List",
type: "GET",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (result) {
var html = '';
$.each(result, function (key, item) {
html += '<tr>';
html += '<td>' + item.Id + '</td>';
html += '<td>' + item.Description + '</td>';
html += '<td><a href="#" onclick="return getbyID(' + item.Id + ')">Edit</a> | <a href="#" onclick="Delele(' + item.Id+ ')">Delete</a></td>';
html += '</tr>';
});
$('.tbody').html(html);
},
error: function (errormessage) {
alert(errormessage.responseText);
}
});
}Thanks
Friday, May 14, 2021 4:44 PM
Answers
-
User-474980206 posted
as I said, just put single quotes around it:
html += '<td><a href="#" onclick="return getbyID(\'' + item.Id + '\')">Edit</a> | <a href="#" onclick="Delele(\'' + item.Id+ '\')">Delete</a></td>';
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, May 16, 2021 3:43 AM
All replies
-
User-474980206 posted
I assume item.Id is not a number nor valid json string, so you need to have quotes around it to generate valid script. As you are using “ for the attribute you should use single quotes,
Friday, May 14, 2021 6:22 PM -
User1979860870 posted
Hi Bruce
Id is a string. Can u pls tell where i need to make changes.
Thanks
Saturday, May 15, 2021 6:40 AM -
User-474980206 posted
as I said, just put single quotes around it:
html += '<td><a href="#" onclick="return getbyID(\'' + item.Id + '\')">Edit</a> | <a href="#" onclick="Delele(\'' + item.Id+ '\')">Delete</a></td>';
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, May 16, 2021 3:43 AM