I have this gridview that is working very well but the problem is the search.
When i inspect the code i saw this error Unexpected end of input
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src=" https://code.jquery.com/jquery-3.5.1.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css" />
<script type="text/javascript" src="https://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="ASPSnippets_Pager.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
GetCustomers(parseInt(1));
var checked = [];
$('[id*=chkSelect]').on('click', function () {
if ($(this).is(":checked")) {
checked.push($(this).closest('tr').find('td').eq(1).html());
} else {
checked.pop($(this).closest('tr').find('td').eq(1).html());
}
$('[id*=hfCheckedIds]').val(checked.join(','));
});
});
$(document).on("click", '.Pager .page', function () {
GetCustomers(parseInt($(this).attr('page')));
});
var term = '';
$(document).on("keyup", 'input[type=search]', function () {
term = $(this).val();
GetCustomers(parseInt(1));
});
$(document).on("change", '[id*=ddlPageSize]', function () {
GetCustomers(parseInt(1));
});
$(document).on('click', '.view', function () {
$('[id*=hfId]').val($(this).closest('tr').find('td').eq(1).html());
});
function SearchTerm() {
return jQuery.trim($("input[type=search]").val());
};
$(document).on('click', '.view', function () {
var id = $(this).closest('tr').find('td').eq(1).html();
$('[id*=hfId]').val(id);
var i = 0;
var row;
function GetCustomers(pageIndex) {
$.ajax({
type: "POST",
url: "JobsV.aspx/GetCustomers",
data: '{searchTerm: "' + SearchTerm() + '", pageIndex: ' + pageIndex + ', pageSize: ' + $("[id*=ddlPageSize]").val() + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$('[id$=gvDetails]').prepend($("<thead></thead>").append($('[id$=gvDetails]').find("tr:first"))).DataTable().destroy();
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("job");
if (row == null) {
row = $("[id$=gvDetails] tbody tr:last-child").eq(0).clone(true);
}
$("[id$=gvDetails] tbody tr").not($("[id$=gvDetails] tbody tr:first-child")).remove();
$.each(customers, function () {
$("td", row).eq(1).html($(this).find("id").text());
$("td", row).eq(2).html($(this).find("pid").text());
$("td", row).eq(3).html($(this).find("description").text());
$("td", row).eq(4).html($(this).find("country").text());
$("td", row).eq(5).html($(this).find("pack").text());
$("td", row).eq(6).html($(this).find("customer").text());
$("td", row).eq(7).html($(this).find("jobnumber").text());
$("td", row).eq(8).html($(this).find("artworkdate").text());
$("td", row).eq(9).html($(this).find("reprodate").text());
$("td", row).eq(10).html($(this).find("artworknumber").text());
$("td", row).eq(11).html($(this).find("templateno").text());
$("[id$=gvDetails]").append(row);
row = $("[id$=gvDetails] tbody tr:last-child").eq(0).clone(true);
});
$("[id$=gvDetails] tbody tr:first-child").remove();
if (i != 0) {
$('[id$=gvDetails]').DataTable({
"paging": false,
"info": false
});
} else {
$('[id$=gvDetails]')
.prepend($("<thead></thead>").append($('[id$=gvDetails]').find("tr:first")))
.DataTable({
"paging": false,
"info": false
});
}
if (term != '') {
$('input[type=search]').val(term);
$('input[type=search]').focus().val($('input[type=search]').val());
}
i++;
var pager = xml.find("Pager");
$(".Pager").ASPSnippets_Pager({
ActiveCssClass: "current",
PagerCssClass: "pager",
PageIndex: parseInt(pager.find("PageIndex").text()),
PageSize: parseInt(pager.find("PageSize").text()),
RecordCount: parseInt(pager.find("RecordCount").text())
});
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
}
</script>
<script type="text/javascript">
function ShowPopup() {
$('#label41').html('');
$("#dialog").dialog({
title: "VIEW JOB DETAILS",
width: 830,
height: 500,
buttons: {
Close: function () {
$(this).dialog('close');
}
},
modal: true
});
$("#dialog").parent().appendTo($("form:first"));
};
function ShowPopup1() {
$('#label71').html('');
$("#dialog1").dialog({
title: "EDIT JOB DETAILS",
width: 830,
height: 500,
buttons: {
Close: function () {
$(this).dialog('close');
}
},
modal: true
});
$("#dialog1").parent().appendTo($("form:first"));
};
function Confirmationbox() {
var result = confirm('Are you sure you want to delete selected User(s)?');
if (result) {
return true;
} else {
return false;
}
}
</script>
</head>