L
L
Legioner9112015-10-19 15:42:16
JavaScript
Legioner911, 2015-10-19 15:42:16

Why does everything stop working when it returns null?

Hello!

$('.md-actuality-date').text(suggestion.data.state.actuality_date);
$('.md-data-management-post').text(suggestion.data.management.post);
$('.md-kpp').text(suggestion.data.kpp);
$('.md-management-name').text(suggestion.data.management.name);


Выводит они информацию сюда получая с сервера:
<p class="md-actuality-date"></p>
<p class="md-data-management-post"></p>
<p class="md-kpp"></p>
<p class="md-management-name"></p>


But as soon as one of them gets nothing. Then the whole script stops working. But if that line which received nothing to comment out. Then the script will work.

Explained like an amateur. How could.

Help solve the problem, so that the script would work even if there is no information from the server.

Sincerely!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GreatRash, 2015-10-19
@Legioner911

Generally strange. It seems like in jQuery this construction works without errors:
But in principle, you can do it more clumsily (if you don’t want to write extra checks):

$('.elem').text('' + suggestion.data.state.actuality_date);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question