0
你好这里是来自AJAX调用我的JSON响应:解码JSON对象
[{"id":null,"period":null,"until":null,"agent_id":"15","agent_zlecajacy_id":"15","offer_id":null,"status":"1","tytul":"Pobranie ksi\u0105g","tresc":"Pobranie ksi\u0105g","data_aktualizacji":"2013-10-21","data_kontaktu":"2013-10-08 22:00:00","data_kontaktu_end":"0000-00-00 00:00:00","czas_minuty":"30","created":"2013-10-21","type":"todo","series":null,"offers":"","details":"","parent_id":"0","assignment":null,"color":null,"asigned_users":null,"e_type":null,"show":null}]
如何获得例如状态是 '1', 我tryed $ .parseJSON(结果),但得到
SyntaxError: JSON.parse: unexpected character
也许因为有空?
这里是更多的代码
url: "/schedule/getDetails/?id="+event_id,
dataType: 'json',
async: false,
success : function(json) {
result = json.result;
console.log($.parseJSON(result));
和PHP(Zend公司)
$result = $model->getDetails($id);
$this->sendJSON($result);
你的反应似乎是一个JavaScript对象,而不是一个字符串。 '$ .parseJSON'接受一个字符串arg。我说的是,你不需要解析..只是从对象中读取。尝试提醒'result [0] .status' –
你确定这是'result'的值吗?我只是尝试'JSON.parse(<您发布的JSON>)',它工作正常。 –
http://jsonlint.com似乎验证您提供的JSON。当试图找出错误实际发生的位置时,更多的代码会让人们更多地使用。 –