How to make loading, search query, ajax?

0 like 0 dislike
8 views
Good time of day. I have search through the database, and, for example, there are 60 000 rows, made so that the first led 100 entries, when you load the first 100, and outputs the normal query, but when there is a reference to ajax to load the trail. 100 records, it starts to give on request.
Request for ajax
$(document).ready(function(){ var inProgress = false; /* Which article to do the selection */ var startFrom = 100; $(window).scroll(function() { /* If the window height + the height of the scroll is greater than or equal to the height of the entire document and the ajax request in not currently running, then run an ajax request */ if($(window).scrollTop() + $(window).height() >= $(document).height() - 200 && !inProgress) { $.ajax({ /* address of file-request handler */ url: 'search_ajax.php', method: 'POST', /* data that we pass the file handler */ data: {"startFrom" : startFrom}, beforeSend: function() { inProgress = true; }}).done(function(data){ /* Convert the result come from the processor - convert json string back into an array */ data = jQuery.parseJSON(data); if (data.length > 0) { $.each(data, function(index, data){ /* Select the ID block with articles and disapointed its new data */ $(".result_search_table").append(""+ data.name + " "+ data.nameScore + " "+ data.organization + ""); }); inProgress = false; startFrom += 100; }}); } }); });

Handler for ajax request
$startFrom = $_POST['startFrom']; $res = mysqli_query($connect, "SELECT * FROM `test_excel` WHERE `noSpaceName` LIKE '%".$startFrom."%' OR `nameScore` LIKE '%".$startFrom."%' OR `organization` LIKE '%".$startFrom."%' LIMIT {$startFrom}, 100"); $resSeacrh = array(); while ($row = mysqli_fetch_assoc($res)) { $resSeacrh[] = $row; } echo json_encode($resSeacrh);
by | 8 views

2 Answers

0 like 0 dislike
Debug your code, find the cause, isolate, and correct it.

It's your work. To begin to make SQL into a separate variable and watch for its value to understand what's wrong.
by
0 like 0 dislike
what are you waiting for?
LIKE '%".$startFrom."%' ... LIMIT {$startFrom}, 100
LIKE '%101%' ... LIMIT 101, 100 -- or LIKE '%learn sql%' LIMIT ... learn sql, 100
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Jun 1, 2019 by Pro-gressive
110,608 questions
257,186 answers
0 comments
33,912 users