Skip to content
Advertisement

Search box value is replaced with page number selected

I am trying to make a search engine using elasticsearch and PHP. I am using AJAX for live data search. It was working fine until I applied pagination. When I applied pagination, my search query was replaced with the page number. i.e. input in the search box was replaced with page number and according documents where retrieved. Here is my code in index.php file:

JavaScript

And here the code in fetch.php:

JavaScript

I can see that in my index.php, my query value of load_data() function is replaced with the page number, that is why it is taking page number as input value. So where am I making mistake? I would highly appreciate any help.

Advertisement

Answer

You are calling load_data with the page number in Javascript : load_data(page) You need to add an extra parameter I think to your load_data.

JavaScript

and in click handler, pass both paremeters

JavaScript

And finally, you should update your PHP code also.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement