Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php

To elaborate on my comments, your issue is here: contentType: ‘application/json; charset=utf-8’, data: JSON.stringify({ action: ‘cdnjs_add_library’, library: library }), When sending data to admin-ajax.php you need to set the action property of data to the action name, eg. cdnjs_add_library. That’s not what you’re doing here. data is not an object with an action property, as … Read more

how can i create get request unis ajax without expecting return value

i have correct my Code and it works now. Order.prototype._downloadDetails = function () { var sServiceUrl = _oController.getServiceUrl(); let iRoleId = _oController.getRoleId(); let iObjectId = _oController.getObjectId(); if (sServiceUrl && iRoleId && iObjectId) { window.open(sServiceUrl +”/download?” + “roleId=” + iRoleId + “&objectId=” + iObjectId, ‘_blank’).focus() } };

Woocommerce – Include custom user meta in order ‘filter by registered customer’ Ajax search

After getting lost with trying to understand the class-wc-ajax.php file, I completely missed a more obvious and simple solution. Here is the code I am using which works perfectly. I hope this helps others looking for similar solution. This filter-hook allows you to add an additional meta_query to the existing search parameters. This will also … Read more

Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?

Avoid using ajax URLs like this when working with ajax calls. Using wp_localize_script is a good way to accomplish this. Let’s assume your js code is in the script.js file. You need to localize that file. function my_theme_enqueue_scripts() { wp_enqueue_script( ‘custom-jquery’, ‘https://code.jquery.com/jquery-3.5.1.min.js’, array(), ‘1.0’, true ); wp_enqueue_script( ‘ajax-script’, plugin_dir_url( __FILE__ ) . ‘js/script.js’, array( ‘jquery’ … Read more

ajax problems on loading page [closed]

I finally find out the problem. The problem is when I load wordpress page a builtin ajax call is started. and this part of my code: jQuery(document).ajaxStart(function() { jQuery( “#step-general” ).hide(); jQuery( “.pelak-loader” ).show(); }).ajaxSuccess(function() { jQuery( “.pelak-loader” ).hide(); }); is used on loading page. I use if conditional in ajaxStart to limit its border!