[英]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.