Created
January 23, 2019 05:11
-
-
Save prondubuisi/5e0c5191e2bd179078092f9eace2b96d to your computer and use it in GitHub Desktop.
Front end for product search App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Product</title> | |
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="panel panel-default"> | |
<div class="panel-heading"> | |
<h3>Products info </h3> | |
</div> | |
<div class="panel-body"> | |
<div class="form-group"> | |
<input type="text" class="form-controller" id="search" name="search" value=""> | |
</div> | |
<table class="table table-bordered table-hover"> | |
<thead> | |
<tr> | |
<th>ID</th> | |
<th>Product Name</th> | |
<th>Description</th> | |
<th>Price</th> | |
</tr> | |
</thead> | |
<tbody id='tbody'> | |
</tbody> | |
</table> | |
</div> | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
const search = document.getElementById('search'); | |
const tableBody = document.getElementById('tbody'); | |
function getContent(){ | |
const searchValue = search.value; | |
const xhr = new XMLHttpRequest(); | |
xhr.open('GET','{{route('search')}}/?search=' + searchValue ,true); | |
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); | |
xhr.onreadystatechange = function() { | |
if(xhr.readyState == 4 && xhr.status == 200) | |
{ | |
tableBody.innerHTML = xhr.responseText; | |
} | |
} | |
xhr.send() | |
} | |
search.addEventListener('input',getContent); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment