0

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.

3

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

  • Knew it was something simple, thank you! Working great now. – APAD1 Apr 3 '18 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.