Delete ACF repeater field row on Front End
You have 1 hardcoded as the row number in mon_action(). It should be delete_row( ‘field_5c8fa4201b65f’, (int) $_POST[‘param’], $post_id );
You have 1 hardcoded as the row number in mon_action(). It should be delete_row( ‘field_5c8fa4201b65f’, (int) $_POST[‘param’], $post_id );
My guess is that the shipping method isn’t initialised when you make an ajax call. Try moving your actions directly into your init function. EG: function checkAjax(){ print_r($_POST); exit; } function dhlsweden_shipping_method_init() { //use checkAjax since you don’t have access to your shipping method class. If this is the case then you need to rework … Read more
I mean is_admin() is to check if you are on the administration so it will return false, so the code inside won´t be executed on the front-end, won´t it ? When you send an AJAX request using this method, you are sending it to wp-admin/admin-ajax.php, which is in the admin. This is explained in the … Read more
Solved by adding an action to handle unauthenticated users: add_action(‘wp_ajax_nopriv_xhrLink’, ‘handleXhrLink’);
If the custom field’s name (i.e. meta key) is correct and the field is enabled for the REST API, then you should be able to update the meta by adding it in the meta property, which is an array of meta key-value pairs, like so: var newColor = { ‘title’: $( ‘.title’ ).val(), ‘meta’: { … Read more
No arguments are passed to the AJAX callback function. Variables passed with the request are available in $_GET or $_POST. So if your function expects an argument, it can’t be used as the hooked callback directly. Your workaround is the correct way to use a function that accepts arguments in an AJAX request.
I think there is a small correction in your code, you just passing page number but you have pass category ID also. I’ve added data-category attribute in load more button. So your archive.twig should like: <section class=”archive”> <p class=”archive__title h-headline text-size-l”>In the same thematic</p> <div id=”archive__list” class=”archive__list”> <article class=”post”> … </article> </div> </section> {% if … Read more
Your hook name uses an underscore: add_action( ‘wp_ajax_save_form’, ‘save_form’ ); add_action( ‘wp_ajax_nopriv_save_form’, ‘save_form’ ); But your action uses a hyphen. action: ‘save-form’ These need to match: action: ‘save_form’ Also, your AJAX callback appears to be in apps/save_signups.php, but you are only requiring that file inside the admin_menu hook: require_once ( ‘apps/save_signups.php’ ); //process submitted form … Read more
This is happening because a separate nonce with the action wp_rest is not being sent by the server to the client and received back from the client in an HTTP request header called X-WP-Nonce with every REST request. To get this working, you will have to generate a nonce like this: wp_create_nonce(‘wp_rest’) …and provide it … Read more
‘X-WP-Nonce’ : Ajax.nonce Was missing that’s why it was giving the error fetch(‘https://mywebsite.online/wp-json/wp/v2/code’, { method: ‘POST’, credentials: ‘same-origin’, headers: new Headers({ ‘Content-Type’: ‘application/json;charset=UTF-8’, ‘X-WP-Nonce’ : Ajax.nonce }), body: JSON.stringify(OurPostData), }).then(response => { console.log(response); return response.json(); });