Javascript SyntaxError:JSON中的意外标记t

Javascript SyntaxError:JSON中的意外标记t,javascript,php,angularjs,json,angularjs-scope,Javascript,Php,Angularjs,Json,Angularjs Scope,我创建了一个angular应用程序,它可以从一个在线可用的api中获取一些数据,首先我从php脚本中获取api信息,然后在angularjs应用程序中获取json结果,但是它给了我一个错误“SyntaxError:json中的意外标记t”,我不明白为什么 我的php: header('Content-Type: application/json'); // jSON URL which should be requested $json_url = "http://iatageo.com/get

我创建了一个angular应用程序,它可以从一个在线可用的api中获取一些数据,首先我从php脚本中获取api信息,然后在angularjs应用程序中获取json结果,但是它给了我一个错误“SyntaxError:json中的意外标记t”,我不明白为什么

我的php:

header('Content-Type: application/json');
// jSON URL which should be requested
$json_url = "http://iatageo.com/getLatLng/OPO";

// Initializing curl
$ch = curl_init( $json_url );
// Configuring curl options

// Getting results
$result = curl_exec($ch); // Getting jSON result string

echo json_encode($result);
控制器:

 $http.get('iata.php').then(function(response){
        $scope.originLatLong = response.data;
console.log($scope.originLatLong);
    });

只需在浏览器中粘贴您的URL,它将返回:

{"latitude":"41.2481002808","longitude":"-8.68138980865","code":"OPO"}true
您将看到错误,因为您从Response获取了所有数据,JSON后面带有布尔参数。 因此,首先检查
responce
var,然后检索所需的有效数据


问候。

什么是
响应
?304未修改如果您尝试解析响应,请尝试$scope.originLatLong=response;当您尝试解析或编码json时会生成这种类型的错误。。我怀疑编码时出现了一些问题。您好,Viktor,我已经尝试过了,但它给了我一个错误“SyntaxError:Unexpected token t in JSON in position 70 at JSON.parse()”,您的响应不是有效的JSON,这就是为什么出现此错误的原因。首先检查响应变量,然后检索正确的子参数。我认为响应已经更新,因为我看不到
}true
更奇怪的是,我仍然看到true,我已经控制台了。记录响应以查看子参数,但当我控制台时会出现此错误。记录响应如果响应已经更新,请,提供JSON响应。