DEV Community

Ajax calls in wordpress front-end

Shweta Danej on December 26, 2019

wp_ajax_ and wp_ajax_nopriv_ actions hooks are used to make ajax calls from wordpress front-end. wp_ajax_ is used when the user is logged in to th...
Collapse
 
lukosevicius profile image
Mantas Lukosevicius • Edited

Hi. I tried both these examples and I'm getting the same error:
POST --my-url--/wp-admin/admin-ajax.php 400 (Bad Request)

Oh, I figured it out, I had to put this to my functions.php, I tried to use it from template file. Thanks, very great examples! I'll bookmark this:)