M
M
Mikhail_mk2019-12-04 11:17:55
PHP
Mikhail_mk, 2019-12-04 11:17:55

JSON data is loading for a long time, how to fix it?

There is a certain search line in which the client enters, for example, a full name

. Each time you press the keyboard, an Ajax request is fired that sends data to the handler, the handler, in turn, returns the answer in this way:
$data = array(
'lead_details' => $output
);
echo json_encode($data);

$output contains ready-made output data.

I accept them just like this on the client side:
success: function(data) {
$('.leed_all_block').html(data.lead_details);
}

Everything works BUT
If there is a lot of data of about 150 lines, then with each click in the search input on the client side, the site starts to freeze wildly, since it does not have time to process and display it all so quickly

Tell me how can I fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mertico, 2019-12-04
@Mertico

No need to process clicks so often
Look at the debounce example: https://habr.com/ru/post/60957/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question