Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Angularjs显示数据库中的数据_Javascript_Angularjs_Phpmyadmin - Fatal编程技术网

Javascript 使用Angularjs显示数据库中的数据

Javascript 使用Angularjs显示数据库中的数据,javascript,angularjs,phpmyadmin,Javascript,Angularjs,Phpmyadmin,基本上,我正在尝试从数据库中删除重复记录,但是,我得到以下错误“SyntaxError:JSON中位置0处的意外标记F” 这是我的密码: HTML PHP 我怀疑您的代码正在执行die(“致命错误:此时服务不可用”)。该字符串的字符0是与您的错误匹配的F JS将尝试解码致命错误:此时服务不可用,这是无效的JSON 不设置http代码,因此AJAX请求将被视为成功。尝试使用以下选项设置代码: 您还应该调整AJAX调用以处理错误: $http.get('includes/functions/gett

基本上,我正在尝试从数据库中删除重复记录,但是,我得到以下错误“SyntaxError:JSON中位置0处的意外标记F”

这是我的密码:

HTML

PHP


我怀疑您的代码正在执行
die(“致命错误:此时服务不可用”)。该字符串的字符0是与您的错误匹配的
F

JS将尝试解码
致命错误:此时服务不可用
,这是无效的JSON

不设置http代码,因此AJAX请求将被视为成功。尝试使用以下选项设置代码:

您还应该调整AJAX调用以处理错误:

$http.get('includes/functions/gettrack.php').success(function(data){
    $scope.data = data;
}).fail(function(){
    console.error('AJAX call failed');
});
或者,您可以更改内返回的字符串,但我建议这并不是修复它的好方法

die('"Fatal error: service unavailable at this time"');

您缺少与数据库的连接

$connect = mysqli_connect($db['hostname'],$db['username'],$db['password'],$db['database']);

您没有显示任何js…错误消息非常清楚:您的JSON有问题。如果您不在此处发布,我们将无法帮助您。请添加更多代码和jsonYep抱歉,编辑时按enter键,我已更新我的帖子。谢谢,这有助于我添加您的代码!我太愚蠢了,忘记了“require_once'../config/db_connect.php';”。
if (!mysqli_stmt_prepare($stmt, $sql)) {
    // Error exists
    http_response_code(500);
    die('Fatal error: service unavailable at this time');
} else {
$http.get('includes/functions/gettrack.php').success(function(data){
    $scope.data = data;
}).fail(function(){
    console.error('AJAX call failed');
});
die('"Fatal error: service unavailable at this time"');
$connect = mysqli_connect($db['hostname'],$db['username'],$db['password'],$db['database']);