[UPDATE]
You should have the page divided in two section-
1. One dealing with AJAX request and Post Method
2. Displaying form data
Here is outline
<?php
if (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' or $_SERVER['REQUEST_METHOD'] == 'POST'){
// Process AJAX Request or POST Method
}
if (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest'){
// HTML Code here which will not be returned to AJAX Call
}
?>
As html code will be returned with ajax response that will cause trouble if not filtered.
Related Posts:
- Plugin Form Submission Best Practice
- $_POST form request with admin-post
- Handling results from data hooked into admin_post
- What is the real intention for admin-post.php?
- What is the recommended way to create plugin administration forms?
- Using AJAX in a plugin to submit form – REALLY confused
- Post from front-end with post types, categories and taxonomies
- Front-End Form Submission in Shortcode
- Check spam in custom form – akismet
- Use a PHP file as action for a form in a WordPress plugin, what’s the correct way?
- Front-End Interfaces Without Shortcodes
- Best Practices for Creating and Handling Forms with Plugins?
- Plugin options page – form with two different submit buttons
- How to sanitize user input?
- WooCommerce registration password field not displaying
- wordpress plugin php file processing form
- How to add custom fields to the all users page
- Error on inserting a form value to database
- Multiple options pages validation for a plugin
- Form doesnt save to database
- Create custom HTML/JS app inside page
- Plugin Development for registered users
- Is there documentation reference for forms in menu and setting pages?
- Input in plugin widget does not allow spaces
- Avoid updating post when sending POST or GET request to post.php
- admin_post equivalent for guest user?
- How can I add a simple custom field to my plugin?
- Run JavaScript validation script on form submit in plugin
- I am unable to save my data from a form
- The Correct Way to Use Nonce Field without Settings API
- How to add search form in main page body?
- How to make and save custom form in custom plugin page?
- Catching Form Submission in WordPress Admin Panel
- Form using admin-post.php gives 404 after submission
- Submit form to a different PHP file in the same plugin folder
- A function that will remove HTML and tags from a string?
- Plugin Form Submitting to admin-ajax.php instead of admin-post.php
- Form submission to another page returning 404 error [duplicate]
- Lead form that submits to 2 external APIs
- WordPress: redirecting to the form page after form submission to admin-post.php
- How to create a custom post-new.php page for plugin , no wp menu
- Information and Page from WordPress Plugin
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Use admin-post to submit form data to external database
- How to Maintain url on form submit
- How to retrieve custom profile fields associated with different users
- form does not generate $_POST request
- Acessing WP functions in form submission handler
- Form and database, plugin development
- Can I use a hook other than ‘init’ to handle form submissions?
- wp_mail links are dead
- Best way to handle a form post in plugin
- Tracing dashboard publish settings from input form in WordPress
- Post data in wp-admin to external database
- Multi-part form and wp_redirect()
- Page reload occurs before request finishes
- Hook a search form anywhere on the site, using a custom plugin
- Plugin forms overwrite each other’s options
- Update Option Stored in Multi-Dimensional Array
- check if Gutenberg is currently in use
- WordPress Plugin Development – Headers Already Sent Message
- Get page content using slug
- Remove profile picture option (and other things) from profile.php (in admin)
- How to disable plugin update notification for a specific plugin in Multisite
- Getting old term value with edited_{$taxonomy} | Hook
- Building a better media uploader for WordPress
- Calling clean_term_cache() fails when called in the same plugin that creates terms, succeeds when called separately?
- Singular name Plugin localization
- On plugin deactivation hide its shortcode
- Can I submit a plugin that follows the PSR-2 coding style guide?
- How to get current page id through the plugin
- OOP Plugin and Menu – Call to undefined function register_setting()
- How to untrash a post only if it was not a draft?
- Calling is_single() outside the loop
- update woocommere total value on checkout based on selected payment method
- Loading WordPress Admin Environment
- Rich text editor settings persist throughout all rich text editors
- WP Gutenberg Blocks – How to limit first/root blocks
- How do I update a field of a meta box?
- Following WordPress Markup Is mandatory, got awkward resultyby wordpress standard markup?
- Are there any official or unofficial guidelines for the styling of a widget?
- How to get error object returned by wp_create_user
- Logout after clicking URL link results in “headers already sent” error
- My WordPress Plugin code breaks customize.php viewpoint
- Make wordpress join default user metas with a column from another table while displaying the wp_users table on the users screen
- $wpdb->prepare is not working like mysql_real_escape_string
- Foreign wp_users ID in custom plugin DB table?
- How to do admin ajax request in a plugin for rest api
- How to show comments from different Plugins to same post type?
- The plugin generated 683 characters of unexpected output during activation
- admin-post.php form handling only working when logged in as admin
- Dont display post with no content
- Custom Admin Plugin – Injecting repeatable select fields (add, remove) into an Ordered List
- React in plugins: REST endpoints vs. regular functions
- Post Pagination does not working on WP-Query
- woocommerce single product page hook not working
- How do I build a settings panel under the plugin
- Multiple Users Logged In Causing Incorrect Account Returned
- How to remove a class [closed]