How to call Ajax in WordPress?

Posted by Prem Tiwari | Updated on

Want to call Ajax in WordPress? Good way to do this is to use wp_localize_script(). Let’s assume your AJAX calls are in my-ajax-script.js file, then add wp_localize_script() for this JS file like so:

After localizing your JS file, you can use my_ajax_object object in your JS file:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers