AJAX requests failing

Dear Sir’s, I’m running my first Local site on windows to develop a WP plugin, and am struggeling with WP throwing 400 Bad Requests when I’m calling Admin Ajax. Not sure if this has to do with Local or if I’m just not doing it rigth. Any suggestions appreciated.

On the backend;

		wp_enqueue_script( 'my_plugin_public', plugin_dir_url( __FILE__)  . 'js/my-plugin-public.js', array( 'jquery' , $this->plugin_name ), $this->version, false );          
		wp_localize_script( 'my_plugin_public', 'my_plugin' , array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );

		add_action( 'wp_ajax_theaction', 'my_action' );

On the frontend:

function clicked() {
        url: my_plugin.ajax_url,
        dataType : 'json',
        type: 'POST',
        data: {
            action : 'theaction'
        success:function(data) {
        error: function(errorThrown){

Hi @duba

We would be happy to assist with your Local troubleshooting! Could you provide some more details to help us take a further look?

  • What is your OS?

  • What version of Local are you on?

  • Please attach a copy of your Local Logs

Keep us posted and we’d be happy to help further!

Edition Windows 10 Pro
Version 22H2
Installed on ‎3/‎28/‎2021
OS build 19045.3570
Serial number PC0P7R6X
Experience Windows Feature Experience Pack 1000.19052.1000.0

Locale: Version 8.0.0+6475
local-lightning.log (6.0 KB)
local-lightning-verbose.log (41.9 KB)

I went through a different sample after creating a new site, and this triggerd the WP php function, so I do expect to find an issue with how I’ve used wp hooks and that it’s not related to Locale as a product


Hi @duba

I’m not seeing any errors in your logging that would indicate a Local issue per see as you pointed out. There might be some useful threads about the web that could help you with this after doing some searching. Here were my results

Nick, really appreciate you spending time on this. Just wanted you to know that I refactored my code after I managed to get simple sample running, and with succcess my plugin actions are running as expected in Local. Basically I did not register the wp hook correctly (and was unsure if Local was to blame).


1 Like

Thank you for the follow up @duba! Happy Developing :green_heart:

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.