douying9296 2017-03-27 11:29
浏览 259

SyntaxError:JSON中的意外标记t

Im creting a angular app that gets some data from a api available online, first i get the api information from my php script than in my angularjs app i go get the json result, but is giving me the error of "SyntaxError: Unexpected token t in JSON ", cant figure out why.

My 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);

Controller:

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

1条回答 默认 最新

  • dongquepao8653 2017-03-27 11:34
    关注

    Just paste your URL in browser, it will return:

    {"latitude":"41.2481002808","longitude":"-8.68138980865","code":"OPO"}true
    

    You getting error, because you took all data from responce, with boolean parameter after JSON. So, check responce var first and then retrieve valid data you need.

    Best regards.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败