使用以下内容我尝试了一百种不同的方法,我得到的就是失败警报 请任何人都能发现我愚蠢的初学者错误
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');
}
});
}
答案 0 :(得分:0)
试试这个,你错过了mysqli_query
$result = mysqli_query($con, "SELECT mycoat FROM $table");
代替,
$result = mysqli_query("SELECT mycoat FROM $table");