Hey, yes it is:
$("#searchInput").on('keyup', function(e){
var query = $(this).val();
if(query.length > 0) {
$(".searchDropdown").empty();
var isProcessing = false;
if(!isProcessing) {
$.ajax({
method: 'POST',
url: 'doSearch',
data: {
query: query
},
beforeSend: function () {
isProcessing = true;
},
success: function (data) {
$(".searchDropdown").empty();
if (data.status === "success") {
$.each(data.spot_list, function (i, v) {
$(".searchDropdown").prepend("<li class=\"dropdown-item\" style=\"cursor: pointer;\"><a class=\"blackColor\" href=\"asd\"><b>#" + v.id + "</b> " + v.text + "</a></li>");
});
if (data.othersResults == true) {
$(".searchDropdown").append("<li class=\"dropdown-item\" style=\"cursor: pointer;\"><a class=\"blackColor\" href=\"asd\"><b>Altri risultati...</b></a></li>");
}
$(".searchDropdown").show();
isProcessing = false;
}
}
});
}
} else {
$(".searchDropdown").hide();
}
return false;
});
But this code in my home works well.
This is the home route:
Route::get('home', function(){
stuff to check if userlogged
});
Problem is in your AJAX method . Your route accept GET request ,but you are trying to POST .
$.ajax({
method: 'POST', // change to GET
})
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community