Proper parsing Json?

0 like 0 dislike
107 views 0 2
Help right start parsing the json to variables by type, image, url, etc ... Json displays about 50 topics. As all of them correctly bring across the variables in the div.

Demo:
snippet
asked by | 107 views

2 Answers

0 like 0 dislike
0 answered by
0 like 0 dislike
0
Right:
fetch('https://woobl.ru/php/api/test/1.php?name=1') .then(response => response.json()) .then(data => data.loads.map(load => console.log(load)));


How not to:
$.ajax({ url: 'https://woobl.ru/php/api/test/1.php?name=1', success: function(response) { var data = JSON.parse(response); data.loads.map(function (item) { console.log(item) }) } });


In General, use the headers in php, and will not have to write JSON.parse()
answered by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Nov 14, 2018 by lexstile
24,510 questions
45,935 answers
0 comments
453 users