Write below code in functions.php of your active theme
<script type="text/javascript" >
jQuery(document).ready(function($) {
var data = {
'action': 'get_data',
'testparam':'hello' //optional to pass any extra param
};
$.ajax(ajaxurl, data, function(response) {
alert('Response: ' + response);
//Append response in your result wrapper
});
});
</script>
<?php
add_action( 'wp_ajax_get_data', 'get_data_ajax_func' );
function get_data_ajax_func() {
global $wpdb;
$param = $_POST['testparam'] ;
$html = "result"; // get data from database
echo $html; //return result
exit();
}
?>
Firebug the ajax request to check its working!
Hope it will help!
Related Posts:
- Adding a Taxonomy Filter to Admin List for a Custom Post Type?
- How to Add a Third Level Sub Menu to the WordPress Admin Menu
- How to export comments in WordPress?
- Where are plugins located
- Admin menu as submenu from another plugin
- Why does WordPress require a ftp server to be running on the webserver to transfer plugins?
- WordPress Admin is displaying Not Available
- Add content to /wp-admin/plugin-install.php admin screens
- Plugin: How to make links in admin page open up inside of the admin panel
- Custom admin column disappearing when using Quick Edit [duplicate]
- How to remove/hide action links cluttering under specific plugins’ names
- Adding Visibility Options
- Plugin Development: WordPress processes twice on post update. How to skip process on the first?
- how to not show plugin in admin area
- “Are you sure you want to do this?” when deactivating all plugins in WordPress 4.3.1 [closed]
- Getting “Fatal error: Call to undefined function wp_cache_get() in option.php” after updating a cache plugin [closed]
- Questions about brute force attacks on the admin username, coming from amazon IP addresses
- Why would WP-CLI and WP Admin show different list of plugins with updates?
- Edits to plugin not taking effect
- How could I execute my plugin just in frontend (not in backend)
- Can’t see login page after migration
- Custom height/width for thickbox in WP Backend
- Hide Theme options and Customize Admin menu
- How can I create a plugin installation link?
- Cannot access wp-admin after disabling all plugin
- How to provide a plugin which requires CMB2 (plugin dependencies)?
- 404 Error on Activate / Deactivate Plugin
- Why isn’t admin_notices displaying my text? [Simple Plugin, Beginner]
- Plugin upload to install
- Change the backend language of a single plugin
- Rotating background images with admin options
- Show an image in my header.php
- How to hide some section in WordPress under Post
- Facebook Messager Plugin
- Polylang : Interverting languages after development [closed]
- Is it possible make a back-end for WordPress with WordPress?
- Create tabs in admin options page from custom post type loop
- Remove ‘Check Compatibility’ from Plugins menu
- Add menu page issues (permissions & position)
- Cannot access my wp-admin after installing Gzip compression [closed]
- Add sub menu page in your plugin
- Plugin settings won’t save changes
- Is there any way to make myself an admin?
- Full list of registered scripts or styles, but from an admin options page
- How can i force wp-admin to use 2-column dashboard layout? [closed]
- Odd /wp-admin/admin-ajax.php entries showing in Wassup
- How can I modify page content in the admin panel?
- Display Plugin Panels Outside of Admin Areas
- How to display terms and conditions in post area?
- Is there a plugin for WordPress for creating ‘Accounts’ where all users who belong to that Account can only see Account data? [closed]
- WordPress Site is Broken, Cannot see wp-admin page [closed]
- How to remove a CPT Menu from the Root Admin only
- Remove value from array within post meta ajax admin
- Is there a better way of handling AJAX requests in WordPress?
- Mowing site to another domain in simplest way
- Get access to WordPress when logged out
- Cannot access WP admin because plugin returns 204
- Install old version of plugin from admin panel?
- WordPress as heavily personalized content management portal, and somewhat like dropbox [closed]
- 404 errors when updating options in admin dashboard
- Can’t save changes or modify settings in Dashboard but Pages and Posts are fine
- Trigger jQuery to add events after AJAX-loading table in admin plugin
- how to move a plugin-block in Edit Post page back to bottom area?
- wp_post not working, keeps redirecting to posts page
- WordPress fatal error from php protocol codes
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function
- Can we hide a certain user in WP?
- How to properly enqueue jQuery knob on WordPress without conflict?
- WordPress Dashboard add user password not working, etc
- Add custom WordPress admin page with pretty url via code
- How to find where an image is used by it’s url
- Get full URL of WP plugin admin page
- WordPress Plugin PHP Not Calling Function
- Admin menu hilighting wrong item for CPT
- Is admin section completely customizable in terms of styling?
- Store admin page into variable
- Not able to upload Plugins/ Theme from Admin backend
- Why does WordPress use cookies for /wp-admin and /wp-content/plugins for non-admin users [duplicate]
- Disable plugin on admin page
- Disable default posts (Posts,Pages,Comments and Media) in wp-admin
- Ajax return 0 in plugin – ajax only used in wp-admin
- How to add php stylesheet to admin section instead of admin_head hook
- How to activate/deactivate menu tab and keep the same id?
- Making plugin to use different table prefix cause permission problem
- Add custom fields in the new and edit the site forms without touching the WP core
- Get post id in Post Page within Wp-admin
- AdBlock blocks my non-advertising sidebar images [closed]
- Combining JS files to one script
- Screen Options drop-down does not show
- plugin translations not reflected in admin dashboard
- Allow direct access to files/folders within WordPress to replace wp-admin
- warning wp session
- WordPress website is redirecting on some different shopping page
- PHP FATAL ERROR
- /wp-admin/plugins.php takes ages to load, and then 404s
- Fatal Error in my WP “Call to undefined function get_option()”
- Secure way to add JS Script to WordPress filesystem
- Not applying update field (acf) in my plugin
- search by meta field in the regular WordPress admin panel search
- Force post update with React