WordPress ajax error 400 bad request for sending data to remote site [duplicate]

Your action name and hooks don’t match. You have hooked to _ajax_news in the hook name: add_action( ‘wp_ajax_nopriv_ajax_news’, ‘ajax_news’ ); add_action( ‘wp_ajax_ajax_news’, ‘ajax_news’ ); But the action you are sending in JavaScript is ajaxnews, without the underscore: ‘action’: ‘ajaxnews’, //calls wp_ajax_nopriv_ajaxnews See how your own comment has a different name than the actual hooks you’ve … Read more

Post data across WordPress sites

You can use url parameters (read more here http://php.net/manual/en/reserved.variables.get.php) but of course you need to create a small function in jQuery / javascript to retrieves those. For instance, placing a link like https://www.websiteb.com?country=yourcountry in your Website A and using a get_url_param(country) jQuery function in your Website B, you could pass the value to the AJAX … Read more

Load oEmbed iframe within ajax call

I figured out that I needed to call specific plateform function to fire the process. In my case Instagram and Facebook : window.instgrm.Embeds.process(); if(typeof FB!==”undefined”){ FB.XFBML.parse(); }

Removing Product from Woocommerce checkout page using Ajax

Use jQuery(‘body’).trigger(‘update_checkout’); on your javascript e.g on ajax success/response it will update checkout page with ajax. $.ajax({ type: ‘POST’, dataType: ‘json’, url: wc_checkout_params.ajax_url, data: { action: “product_remove”, product_id: product_id, cart_item_key: cart_item_key }, success: function(response) { if ( ! response || response.error ) return; var fragments = response.fragments; // Replace fragments if ( fragments ) { … Read more

How to use `foreach()` in ajax call

I see that you found the error in the comments given to you on the post, and that is good. However, it should be pointed out that your code contains both an SQL Injection vulnerability, as well as a Reflected XSS vulnerability. $catId = $_POST[‘key’]; // value from the ajax … $result_fromDB = $wpdb->get_results(“SELECT * … Read more