JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/cowboy/jquery-throttle-debounce/v1.1/jquery.ba-throttle-debounce.js"></script>
<input type="text" class="prod-name-input"/>
JavaScript
var ajaxReq = null;
$(".prod-name-input").keyup(function() {
searchword = $(this).val();
if (ajaxReq != null) ajaxReq.abort();
ajaxReq = $.ajax({
url: "/echo/json",
type: "post",
data: {
json: "test"
},
dataType: "json",
success: function(data) {
ajaxReq = null;
console.log(data);
},
delay: 1
});
});