我通过使用PHP的AJAX调用从MySQL接收文本。当我尝试JSON.parse(string)
我得到一个错误。我验证了我的JSON,结果MYSQL给了我一些JSON无法处理的UTF-8值,我该如何解决这个问题,以便我能在客户端解析它?
While we'u2019re still waiting...
样本Javascript: module.controller('OrdersController', function($scope, $http){
$http.get(base_url() + 'orders/?position=' + position)
.success(function(data){
console.log(jQuery.parseJSON(data));
});
$http
查看标题中的Content-Type
并为您解析字符串为对象,如果需要
data
参数,因为它是:
$http.get(base_url() + 'orders/?position=' + position).success(function(data){
console.log(data);
});
关于$http的一些有用信息(查看设置http头)