Answer the question
In order to leave comments, you need to log in
How to properly implement json loading?
How to properly implement json loading? The essence of the question is that: let's say there is a json load. and there is html where the whole thing is inserted - let's say
<div>
<div>Новость 1</div>
<div>Содержание новости</div>
<img // >
</div>
Answer the question
In order to leave comments, you need to log in
If you receive a response from the database and implement your code for manipulating the DOM, then just make a loop with a check, for example, for the existence of the image field in the news object if(news[i].image) {...} and, accordingly, if there is something - add to the structure, if not, then exit the subroutine and check further.
upd. If an empty value comes from the database in the image field (or any other), then check not the existence of this field, but its contents)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question