Proper parsing Json?

0 like 0 dislike
71 views
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 | 71 views

2 Answers

0 like 0 dislike
answered by
0 like 0 dislike
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,509 questions
45,931 answers
0 comments
310 users