Thanks Muhammad,
Your solution is a fantastic working framework on which to base real world AJAX calls.
I just added this code to the plugin main php file for a shortcode so I could use it in the Front End too.
//For front end use in production
add_shortcode('wp_testingPlugin_shortcode', 'wp_testingPlugin_shortcode');
function wp_testingPlugin_shortcode() {
wp_enqueue_script( 'ajax-script', plugin_dir_url( __FILE__ ).'my_javascript.js', array('jquery') );
wp_localize_script( 'ajax-script', 'my_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
return '<form id="searchForm">
<input name="WhatToSearch" type="text" />
<input type="submit" value="Search"/>
<input type="reset" value="Reset"/>
<div id="showReturnData"></div>
</form>';
}
Related Posts:
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- How to create popup same as wordpress popup feature
- AJAX update fails for public/non-admin users
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Ajax, jQuery and WordPress
- Load css classes after using ajax calls
- What’s the preferred method of writing AJAX-enabled plugins?
- How do I only load a plugin js on it’s settings pages?
- How to pass JavaScript variable to PHP in wordpress widget?
- Create Proper WordPress Ajax Request in JavaScript, NOT jQuery
- Execute a function using ajax
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- ‘Lazy loading’ list of posts with pagination
- Errors while using ajax from external wordpress page
- Built in admin ajax hooks?
- How to include admin-ajax when loading external javascript
- How to use wp-ajax in wp-cron
- Dequeue / Deregister script and replace it with a new plugin
- Insert code after tag without using functions.php?
- how to use ajax to display from database and load more in wordpress plugin
- Passing select control value to block
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- How do I store information in a dynamic block in WordPress?
- $wpdb working with ajax but showing ajax error instead of success
- Ajax gives 400 error
- Check if email address exists front end with AJAX in a plugin
- WooCommerce get_price returning wrong price when used via ajax
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- React JSX in WordPress Plugin Development
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Simple ajax call not working in wordpress plugin
- Best approach to fetch data from wp options to js file or php file
- AJAX search posts and pages
- __callStatic method handler passed to add_action causes bug in PHP
- Enqueue WordPress plugin scripts below all other JS
- How to add Internationalization in WordPress using Javascript/React?
- Using a custom plugin to capture input data via Ajax and PHP
- Ajax contact form widget plugin data not insert in database
- Best place for if/else piece of code related to custom plugin?
- Ajax call returning 0
- Create tabs in admin options page from custom post type loop
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- What are the Best Practises When Using AJAX in Plugin Development?
- Redirect to another page using contact form 7? [closed]
- Delay JavaScript files from loading
- Submit Form data to another page via Ajax (WordPress Way)
- wordpress add_action() issue in ajax call
- Using WordPress to build membership Page
- How to get specific string/value from an array? php [closed]
- How to use custom Javascript code inside a plugin?
- Is there a better way of handling AJAX requests in WordPress?
- WordPress API functions not working at AJAX functions.php call
- how to request a script more than once in wordpress
- Ajax request sends url rather than data
- best way to run a php script away from the template?
- Ajax call not working in wordpress through a plugin
- Send Array from JS to php file then insert it in wp database through a plugin
- can’t unzip file
- Set Button in PluginDocumentSettingPanel Content (WordPress Gutenberg)
- wp_query ‘s’ parameter does not work with WC_AJAX
- wc_get_template_part doesnt display the content [duplicate]
- Jquery POST Ajax Return null data in wordpress
- Fixed: Console.log twice in the edit function
- Cannot run script properly with my custom plugin
- Trouble with AJAX using GET
- Add style to body based on url
- How to properly enqueue jQuery knob on WordPress without conflict?
- Ajax Call not Working in Plugin
- JS working when used normally but not in wordpress
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- How to use Datatable with Ajax when creating plugin on WordPress?
- Problem with wordpress has_action() function
- Create a form and have custom menu display based on user answers?
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- How to disable/enable PHP plugin functionality based on a TinyMCE toggle-button
- ajax voting for custom post type
- Conditional Fields depending on checkboxes
- WordPress environment not loading properly
- wordpress ajax pagination object value does not change
- How can I use wp_ajax_response for front-end error reporting?
- Creating a user ‘add custom field’ section
- Javascript not working
- WordPress ajax not working in registration
- What’s the preferred method of writing AJAX-enabled plugins?
- Need to hide an element depending on date and post category
- How do I convince this button to do something when it is clicked?
- Plugin – including external javascript calling google maps
- Is it possible to run javascript on plugin deactivated?
- Help me with my first very basic plugin
- Ajax in Plugins: returns the whole page
- How to create post comparison in wordpress
- Jquery post responses 500 error after some time and lastly an 503 error
- Inline AJAX script passing variables to PHP
- Select posts from list and add them in a new list
- wordpress admin-ajax bad request 400
- Vanilla javascript in custom gutenberg block not working
- Ajax response from Media Selection does not update ALL information more than once