在$http文档中,我被告知在响应前加上)]}',n
,我如何在PHP中做到这一点?完成后如何访问返回的数据对象?
error(function(data, status, headers, config) {
$scope.error = data.error;
});
echo json_encode(array('error' => $error)); //You messed up Leroy!
以下内容应该有效。
echo ")]}',n" . json_encode(array('error' => $error));
关于angular:我认为你的函数是正确的。但如果它不起作用,它对console.log(data)
和查找它的结构是有用的。