How to Post Data Using Ajax in WordPress

Hi friends, hope you are doing good. In today tutorial, I will explain how to post data using ajax in WordPress without using any plugin and also without creating a new plugin.

In this tutorial, I will show you how to get data from database by using the ajax in WordPress with the help of functions.php without using any plugin, so keep your close attention in this post. Please make sure you have already included the latest version jQuery. You can download the latest version of jQuery from here:

How to Post Data Using Ajax in WordPress

How to Post Data Using Ajax in WordPress

Open your functions.php file from your current activated WordPress theme folder and add the below code at the end the file and save. This function will include the autocomplete JS and autocomplete CSS in your site.

Now create a jquery.custom.js file in your JS folder and add below code snippet. The below code will post the user input data from search textbox to fwm_autocomplete function which is written in functions.php file.

Now again go to the functions.php file and copy paste below code at the end of the file and save. Below code will fetch the data from the database table based on the user_input data and return in JSON format. You can use that data where you want.

Over to You

Hope this tutorial help you more, do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:

Article Tags: , , , , , , , , ,