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

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!