I have a form which is in a sidebar, and shows on multiple pages. If the user is on page-a.php and submits the form, it uses ajax to return some data to a div on that page.
However, if the user is on page-b.php and submits the same form (again, it is included on both pages), I want the form to redirect to page-a.php and then use the same ajax post to load the data. How can I achieve this?
Edit for clarity:
page-a.php – when this submits this form (included from separate file), an ajax call is made to page-c.php, which loads data into the div:
<form method="post" action="page-c.php">
<input ....
/>
</form>
<div></div>
page-b.php has the exact same form (included from a separate file), but different content, so in order to load the data into the div, we need to redirect to page-a.php:
<form method="post" action="page-c.php">
<input .....
/>
</form>
So how can I make the form call work the same (ajax that is already implemented), but have it redirect me to page-a.php first?
Solved it using this:
with this on page-a.php to auto submit the form on page load, which redirects the load to the ajax submit