1

I am attempting to create an AJAX call to pass custom taxonomy into my WP_Query but I am getting 400 (Bad Request). I believe my data array is built correctly so I am not sure what's causing it. Does anything look off here? Is there a way for me to get a more detailed error of why it is returning error 400?

$.ajax({
    type:'POST',
    url:ajaxUrl,
    data: {
        taxonomy: 'products',
        slug: 'shirts'
    },
    beforeSend:function(xhr){

    },
    success:function(data){
      $('#response').html(data); // insert data
    }
});

I console logged ajaxUrl and I am getting the correct path to admin-ajax.php so I know that's not the issue. I think it has to have something to do with data.

1 Answer 1

7

you forgot the "action" key in your data array. With that key you define which function is called from your plugin or function.php File. For more information see the Wordpress documentation - AJAX in Plugins

1
  • Knew it was something simple, thank you! Working great now. Commented Apr 3, 2018 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.