[英]php ajax connection failure
使用以下方法,我嘗試了一百種不同的方法,而我得到的只是失敗警報。任何人都可以發現我愚蠢的初學者錯誤
myy.php
$con = mysqli_connect('adress','dbase','pass','table');
$result = mysqli_query("SELECT mycoat FROM $table");
$response = array();
while($array = mysqli_fetch_row($result)) {
$response[] = $array;
}
echo json_encode($response);
JavaScript:
function myfunction()
{
$.ajax({
url: 'myy.php',
dataType: 'json',
success: function() {
alert('success');
},
error: function() {
alert('failure');
}
});
}
試試這個,你錯過了mysqli_query
數據庫連接鏈接
$result = mysqli_query($con, "SELECT mycoat FROM $table");
代替,
$result = mysqli_query("SELECT mycoat FROM $table");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.