How can I access the Header of and ajax response from the rest API

You can use change ajax this: request.getResponseHeader(‘your_header’) $.ajax({ type: ‘POST’, url:’api-url.php’, data: formData, success: function(data, textStatus, request){ alert(request.getResponseHeader(‘your_header’)); }, error: function (request, textStatus, errorThrown) { alert(request.getResponseHeader(‘your_header’)); } });

Increased CPU load due to admin-ajax.php spam

No there isn’t a way, any more than there is a way to block “spammers” from accessing you home page. I mean you could put all kind of checks, but in the end you will break how sites are supposed to behave which will mean that someone somewhere will not get his content. If all … Read more

wp_ajax function did not call

Finally I’ve found the problem in your code. You’ve forgotten \ on namespace path. class OtherClass{ public function __construct(){ add_action(‘wp_ajax_getItemsByAjax’, array( ‘\Namespace\Common\FooClass’, ‘getItemsByAjax’ ) ); } } I hope it will help you.

Admin-ajax.php 400 error

You have two problems in PHP you need change this is bad: wp_localize_script( ‘customjquery’, ‘ajaxurl’, admin_url( ‘admin- ajax.php’ ) ); change to: wp_localize_script( ‘customjquery’, ‘my_custom_vars’, [‘ajax_url’ => admin_url(‘admin-ajax.php’)] ); and your javascript need this changes is bad: $.ajax({ type: ‘POST’, // use $_POST method to submit data dataType: “html”, url: ajaxurl, change to: $.ajax({ type: … Read more

Ajax WordPress Login needs to be stayed in current page Url without redirecting

Please try following code it will works for you. Please add this in your functions.php for getting current page URL /*Get Current Url */ function currentUrl( $trim_query_string = false ) { $pageURL = (isset( $_SERVER[‘HTTPS’] ) && $_SERVER[‘HTTPS’] == ‘on’) ? “https://” : “http://”; $pageURL .= $_SERVER[“SERVER_NAME”] . $_SERVER[“REQUEST_URI”]; if( ! $trim_query_string ) { return … Read more