$( "#polePoiska" ).on('keyup input', function() {
var value = this.value;
if (value.length > 3) {
$.get( "/search?q="+value, function(data) {
document.getElementById('searchResult').style.display = 'block'
$.each(data, function (data_key, data_val) {
$("#tablePoisk tr").remove();
$("table.tableSearch").append("<tr><td>" + data_val.title + "</td><td>" + data_val.pharmacy__title + "</td><td>" + data_val.balance + "</td><td>" + data_val.price + "</td><td>");
});
});
} else {
document.getElementById('searchResult').style.display = 'none'
}
});
<script type="text/javascript">
var app = new Vue({
delimiters: ['[[', ']]'],
el: '#main',
data () {
return {
medicines: [],
searchText: ''
}
},
methods: {
searchEvent ({ type, target }) {
if (target.value.length > 3) {
document.getElementById('searchResult').style.display = 'block '
var textStr = target.value
axios.get("/search?q=" + textStr.toUpperCase())
.then(response => {
this.medicines = response.data
})
.catch(e => {
this.errors.push(e)
})
} else {
document.getElementById('searchResult').style.display = 'none'
}
}
}
})
</script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.min.js"></script>