Skip Navigation

[Resolved] Ajax pagination causing search with unsubmitted input field data

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 7 replies, has 2 voices.

Last updated by Mateus Getulio 1 year, 7 months ago.

Assisted by: Mateus Getulio.

Author
Posts
#2617809

I have created a toolset archive and added search fields for frontend search. And I kept the pagination of the archive to ajax infinite scrolling. Now when I provide any value in the input fields but don't press the submit button and go to the bottom of the archive to see more results with infinite scrolling, it automatically searches according to the new input value that I provided in the input field. So it shows different results. But it should provide results according to the past value of the input field because I didn't press the submit button. It is showing results according to the new value of the input fields. Is there any way to stop it?

#2618117

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thanks for your contact! I'll be glad to help you 🙂

It is possible to achieve that behavior, yes. For this you'll need to:

- select the 'View Search' block
- find the 'Custom Search' metabox
- choose the second option for 'Form submit': AJAX refresh when clicking submit
- save the page and see if you'll have the desired results

Please check the following screenshot showing this step-by-step: hidden link

If something is not clear yet or it is not working properly, please let us know and we'll check it better for you.

Looking forward to your reply.

Kind regards,
Mateus.

#2618639

Hi there,
Thanks for your answer. I checked my archive page and found that, the option is already enabled. The page does ajax refresh upon clicking submit. But the problem is still occurring. What else can I do?

#2619009

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thanks for your reply.

Could you please show us where exactly the View and Search appear? Also, I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://toolset.com/privacy-policy-and-gdpr-compliance/#data-shared-with-our-support
**IMPORTANT**

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

Please, let me know if you need any additional details. Have a nice day.

#2619719

Hi there. I am actually not comfortable in giving access to my developed website. Can you kindly give me a sandbox site where I can replicate the problem and show it to you?

#2619755

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thanks for your reply.

Sure thing. Here it goes an automatic login link to a Sandbox having only the Toolset plugins and a default theme: hidden link

Please access it, try to replicate the issue and tell us the exact step-by-step you've followed. Thank you.

#2620953

I have created some posts and assigned them to some category terms. I also created a Home archive with Toolset where I used infinite scrolling. You can visit it here: hidden link

1. Go to hidden link
2. Don't scroll the page and select any checkbox in the Archive search
3. Now scroll the page for infinite scrolling

You will see that, the archive isn't showing any result. But it should show all the default results of the archive.

Thanks for your patience. Looking forward to your reply.

#2621105

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thanks a lot for your efforts in doing the replication.

Upon further inspection, we have concluded that the question you've reported is actually an expected behavior. The reason behind it is that the 'submit' action sends a request to the server, which has collected info from the search filters and will be used in constructing the query. Then, the results (including the search filter values used to generate it) are passed to the browser. After the request is completed, the server knows nothing about the form search parameters. Every browser request needs to re-send them.

Then, we have a problem because going to the next page of results (pagination) is also a request to the server, and the request again includes details of the parameters to be used in the query, including the search parameters as well as which page of results to return. The only source for the search parameters is what's in the search form; what's in the form at the time of the request gets sent along with the rest of the request details.

A pagination request and clicking the submit button are functionally equivalent, both triggering requests to retrieve posts with whatever the current parameters are. Therefore, what we're experiencing in this archive is just the expected scenario and we can't avoid that.

I hope this explanation is clear to you and solves the question.

Please let me know. Thank you.