ajax response not recieving

As per jQuery documentation, dataType: ‘json’ is supported. That is the thing that is being returned and parsed by jQuery to your success function. There is more information needed to resolve your issue. Does pin_shop.ajax_url properly resolve to //site.com/wp-admin/admin-ajax.php? If not, there’s your first problem. (To check this, console.log(ajax_url); just before your $.ajax call. I … Read more

Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”

It’s working, I traced it by digging through admin-ajax.php to see what was responding with 401/400. My fix was basically making the action parameter the last thing appended to the formData formData.append(“enquiry”, form); formData.append(“action”, “enquiry”); I don’t normally use formData to post things, .serialize() has always been enough for me over the years. As I … Read more

Why, if a function accepts arguments, it fails on ajax calls?

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.

Load more posts in the same category – Ajax + Timber

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

ajax form is returning the dreaded “[HTTP/1.1 400 Bad Request” and a zero

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