otariterterashvili
10/9/2018 - 11:56 AM

ajaxSearchCallJs

Ajax search call in javascript.

// Search ajax
	$("#query").keyup(function () {
		$(".list").remove();
		var query = $(this).val();
		$.ajax({
			url: '/Home/Jindex',
			method: 'post',
			data: { 'query': query },
			success: function (response) {
				var reasultHtml = '';
				$.each(response, function (key, value) {
					if (value.IsAllowed === 100) {
						var allowTitle = "გაყიდულია";
						reasultHtml += '<tr class="list"><td><a href="/Home/GetTicket/' + value.Id + '">' + value.Id + '</a></td><td>' + value.Name + '</td><td>' + value.LastName + '</td><td>' + value.IDnumber + '</td><td>' + value.SoldDate + '</td><td class="soldItem">' + allowTitle + '</td></tr>';
						console.log(value.SoldDate);
					}
					else {

						tittle2 = "გაყიდვაშია";
						reasultHtml += '<tr class="list"><td><a href="/Home/GetTicket/' + value.Id + '">' + value.Id + '</a></td><td>' + value.Name + '</td><td>' + value.LastName + '</td><td>' + value.IDnumber + '</td><td>' + value.SoldDate + '</td><td>' + tittle2 + '</td></tr>';
					}
				});
				$(".table").append(reasultHtml);
			}

		});
	});
	// Search ajax end