Handle Ajax in WordPress | WP

Okay, this is probably already all over the internet, I’m just adding this as reference to myself in case I need a reminder. If you have any questions and not sure how to deploy it, do not hesitate to ask for help in comments section below.

This can be used in your theme’s functions.php or in your plugin.

This needs to be added to your theme’s or plugin’s javascript file or if you prefer you can paste it inline.
in that case don’t forget to wrap it with