I got everything working but it may not be the most elegant of solutions.
I put the form text as well as the empty results div on a page. I created a small plugin that checks to see if we are on that page. If so, insert the JavaScript into the footer. Otherwise, do nothing.
This checks for the page we are on:
public function display_group_information($content)
{
global $post;
if ($post->post_name == 'groups-activities-and-events'){
add_action('wp_footer', [$this, 'load_group_ajax']);
}
return $content;
}
This adds the required javascript:
public function load_group_ajax(){
?>
<script>
!function(r){function n(n).....("#grpSearch").submit(n)}(jQuery);
</script>
<?php
}
Again, probably not the most elegant way of doing it but it works.
Related Posts:
- Allow only new sub-pages to be created
- Add a new page to wordpress programmatically
- AJAX request from Chrome Extension to WordPress Website
- What’s the most minimal way in which a page can be hooked into WP?
- Call the content of a page in AJAX in WordPress
- How to add WP API and JS featured image attachment
- How get get list of pages in ajax search
- Can’t get done anything with admin.php response
- Loading Multiple Comments Pages via Ajax?
- Is it possible to create new user from external form using REST API?
- How To Render Shortcode In AJAX Response?
- Create multiple pages with tables from json file
- register_rest_field only for specific page
- My AJAX requests take 30 seconds to complete
- List of pages – AJAX load more
- How to submit a button automatically after every scheduled hours?
- How do I use the WP REST API plugin and the OAuth Server plugin to allow for registration and login?
- Some pages are missing from the Parent Page select in the Editor
- Does the REST API (official) support custom post types?
- Custom Search Page Pagination Not Working
- Dynamic content in a static page
- Displaying Child pages of the current page in post format and their thumbnails (featured image)?
- How do I create multiple page while active a theme
- Static files or dynamic WP pages for “static content”?
- Child page from 2 different parent pages
- Redirect “Sorry, you are not allowed to access this page.” to Home
- select a private page as parent for another private page
- node-wpapi: how to handle authentication?
- Can I set a timer for pages to be published?
- Add a Menu Link (to a WordPress Page) in the Admin Menu/Sidebar
- Too Many Pages in WordPress? 2013
- How can I automatically add child pages to pages in a WP menu?
- Job Manager plugin help?
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- Give access to a simple .html file to users that bought a specific ‘digital product’
- What would be the best way to implement Magic Link logins in WordPress?
- How to make tag post listing page working?
- Adding custom end points, No error line
- Admin pages, edit notes of the title of posts and pages
- Calling an API to do authentication / user login
- Unique page URL redirect to file_get_contents() at domain
- body_class REST field in WP-API
- Best option to implement external register/login to WP from self-made API
- Redirect page to default subpage
- Special Character Appearing in my WordPress Pages Content
- WordPress pages creation work distribution & then combining – Localhost XAMPP
- Prioritize visible content – Page speed issue on Google insights
- Getting a Page via its post-name using WP REST API v2 and Postman
- How can I check user capability when a page loads (via functions.php)?
- How to have a next page for post?
- Bad pages redirection
- How to make a fetch() POST request to wordpress rest api?
- Is there a way I can fetch the WordPress Developer Code References with an API?
- Remove_filter (‘the_content’, ‘wpautop’) only pages
- Weebly Migration to WordPress [closed]
- Need to create a custom page on a website
- Do I have to widgetize my pages?
- Page templates in subdirectories and auto generator
- Password Protect Pages Not Working
- Can I connect a page to a taxonomy?
- How to control display of page lists on sidebar that doesn’t have childrens
- wp_nav_menu: output featured image of each page listing
- Is there a template tag/function for getting the URL (or slug or name or ID) of the blog page when using a “static” front page
- Problems in creating a static site with WordPress
- Creating new page/tab in groups section not working! [closed]
- Change displayed “page name” to distinguish multiple pages with the same title
- add title to widgets of wordpress
- Custom user tables not working after migration
- remove “Edit” from select pages
- GET request return value as error instead of success
- How to query a nested field in wordpress api using _fields param
- How to transfer a site to hosting?
- Add custom action to the page listing screen
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- How can a .css file be applied to a virtual page?
- WordPress blog posts template bug [closed]
- Checkboxes to automatically create pages when I activate a theme
- Cannot use old slug – it just 301s to site home page
- Display inner pages like posts.[Like how post excerpt works]
- include exception inside theme for empty widget area
- My pages disappeared from the list
- Pre-populating new Page creation with shortcodes
- How to display time when page is created and edited
- Access wordpress pages using a self signed shared ssl
- Page loads all pages of the image gallery with pagination
- Group Pages based on Parent in Admin Area
- How to exclude page in pages module
- get id custom tables on current page
- static page with buton that opens collect email form
- Parent for a single (single.php)
- Multiple WordPress Pages
- How to create an user defined page?
- How can one get page by pagename if it is a child page?
- multi-language multi-site with REST API
- WordPress API standard compliance and specification for external database [closed]
- Output the published date / last modified date of specific page
- How to remove container box in WordPress pages? [closed]
- Update post / page using API + python
- Is it possible to create post in wordpress using postman?
- Issue with API after 6.2 update