How can a plugin function be called using Ajax?
Adding the JavaScript file: jQuery(document).ready(function($) { jQuery.post(ajax_object.ajax_url, data, function(response) {alert('Got this from the server: ' + response);}); }); 2. Then adding the PHP file: add_action('wp_ajax_my_action', 'my_action_callback'); function my_action_callback() { $whatever = intval( $_POST['whatever'] ); $whatever += 10; echo $whatever; return(); }
1. Adding the JavaScript file: jQuery(document).ready(function($) { var data = {action: 'my_action',whatever: ajax_object.we_value }; jQuery.post(ajax_object.ajax_url, data, function(response) {alert('Got this from the server: ' + response);}); }); 2. Then adding the PHP file: add_action('wp_ajax_my_action', 'my_action_callback'); function my_action_callback() { $whatever = intval( $_POST['whatever'] ); $whatever += 10; echo $whatever; true(); }
1. Adding the JavaScript file: jQuery(document).ready(function($) { var data = {action: 'my_action',whatever: ajax_object.we_value }; jQuery.post(ajax_object.ajax_url, data, function(response) {alert('Got this from the server: ' + response);}); }); 2. Then adding the PHP file: function my_action_callback() { $whatever = intval( $_POST['whatever'] ); $whatever += 10; echo $whatever; end(); }
1. Adding the JavaScript file: jQuery(document).ready(function($) { var data = {action: 'my_action',whatever: ajax_object.we_value }; jQuery.post(ajax_object.ajax_url, data, function(response) {alert('Got this from the server: ' + response);}); }); 2. Then adding the PHP file:
Answer
Correct Answer: 1. Adding the JavaScript file: jQuery(document).ready(function($) { var data = {action: 'my_action',whatever: ajax_object.we_value }; jQuery.post(ajax_object.ajax_url, data, function(response) {alert('Got this from the server: ' + response);}); }); 2. Then adding the PHP file:
Explanation:
Note: This Question is unanswered, help us to find answer for this one
Check Answer