Answer the question
In order to leave comments, you need to log in
Parse JSON array?
$.ajax({
url: "assets/ajax.php",
dataType: "json",
success: function(data){
console.log(data);
}
});
({"cnt_pay_s":"1 523","cnt_pay_z":"22 924","cnt_pay_a":"29 587","cnt_z":"227 450","cnt_s":"7 456","sum_z":"2 544 060 000","sum_s":"1 723 330 000"})
Answer the question
In order to leave comments, you need to log in
You can trim the brackets, like this: data.slice(1, -1)
, for example .
But it is better, if possible, to correct the server part, the one that adds these extra brackets.
success: function(data){
data = JSON.parse(data);
console.log(data);
}
Uncaught SyntaxError: Unexpected token ( in JSON at position 0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question