Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
Proper parsing Json? - bug-code.com Q&A

Proper parsing Json?

0 like 0 dislike
118 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 | 118 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
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers

0 comments

12.8k users

24,788 questions
46,220 answers
0 comments
12,813 users