我再次在我的代码中使用 ajax。我正在为我的项目制作实时搜索 ajax 系统,但是当我将数据发送到 search.php 和 var_dump POST 数组时,我得到了空的 post 数组。
AJAX
function searching(string){
$.ajax({
url : "request/search.php",
type : "POST",
data : "search="+string,
type : "text",
beforeSend : function(http){
},
success : function(response,status,http){
alert(response);
},
error : function(http,status,error){
$('.response').html("<span class='error'>Something went wrong</span>");
$(".response").slideDown();
}
})
}
HTML
<form id="searchBox">
<p>
<input type="text" name="search" id="search" onkeyup="searching(this.value)" placeholder="Search here">
<button class="find" data-icon=""></button>
</p>
</form>