jquery & ajax getting data to php in wordpress

Assuming that your script localization and other stuff are set up properly, there is an issue in your back-end script. Your data is in the following format: data : { action : ‘renove_vocabulary’, id_vocabulary : vocabulary, id_user : user } But you are trying to get the data as follows: $id_user = $_POST[‘user_id’]; $id_vacabulary = … Read more

Can i check if user is doing any ajax request?

You’d be better off moving your function that updates the meta to a hook that runs on the front end and during AJAX calls. Then you don’t need to bother about checking if the request is an AJAX request or not. init is a good choice for this: function wpse_297026_update_user_activity() { update_user_meta( get_current_user_id(), ‘last_activity’, time() … Read more

Custom Shortcode AJAX 400 Bad Request

The problem is that you’re attempting to use the arguments for the jQuery AJAX API with the native Fetch API. Specifically, the problem is that the JS Fetch API doesn’t support a data argument. For an admin-ajax.php request to work in WordPress the $_REQUEST[‘action’] property needs to be populated, and to do this with the … Read more

Metabox cloning via Admin Ajax call issue

1st This isn’t a WP problem, but a jQuery problem. 2nd I used to develop my own set of classes for meta box and stopped about a month a ago and dropped them in favor of the RW Meta Box library. Meta Boxes are a big issue incl. saving the data, building an endless # … Read more

How-to debug wp_ajax_* hook callback?

The answer was as stupid as simple: I wrapped the init for the class in a ! is_admin() call. This successfully prevented the callback from beeing fired. Rule for AJAX loading Load it in public Don’t hide it behind a ! is_admin() call. The 2nd line from admin-ajax.php define( ‘WP_ADMIN’, true );

Load posts dynamically

Here’s how I’d approach it. Let me know in the comments if you need more detail. 1) Create a template that pulls back your initial page content — the default right panel content and the list of links for the left panel. Ensure the links have post_id set as the value of the id attribute. … Read more