$data = '{"auth": "true", "user": "ckmp", "status": "ok", "return_count": "1", "return": [{"id": "109", "situation_id": "3487", "datetime_add": "2019-03-19 07:27:47", "description": "\'test\'"}]}';
$data = JSON.parse($data);
console.log($data);
{"auth": "true", "user": "ckmp", "status": "ok", "return_count": "1", "return": [{"id": "109", "situation_id": "3487", "datetime_add": "2019-03-19 07:27:47", "description": "\'test\'"}]}
(index):868 123
(index):869 34
VM341:1 Uncaught SyntaxError: Unexpected token ' in JSON at position 175
at JSON.parse (<anonymous>)
at (index):870
at XMLHttpRequest.r.onreadystatechange ((index):856)
Uncaught SyntaxError: Unexpected token ' in JSON at position 175
function load($url, $mutation, callback) {
var $token = getCookie('token');
ajax($url + '&token=' + $token, function($data){
$data = JSON.parse($data);
if ($data['auth'] == 'false') {
$store.commit('ADD_MODAL', {'visible': true});
$store.commit('ADD_MODAL', {'template': 'auth'});
$store.commit('ADD_MODAL', {'type': 'auth'});
$store.commit('ADD_SELECT_ACTION', 0);
} else {
$store.commit($mutation, $data['return']);
updateCookie('token');
}
if (callback != undefined) callback();
});
}