Posted in WordPress

Working with WordPress Ajax

Working with WordPress Ajax Posted on December 5, 2015Leave a comment

Today, I’m going to show you how to use Ajax in WordPress with an easy example step by step.

In our example, it uses Ajax to get post title from post id in an input.

Step 1: Write a text input to enter post id, a button that will be clicked to get post title and a div to show the result.

Step 2: Create an Ajax function that gets post id and sends post title if it’s existed.

Step 3: Enqueue script and pass some variables to Javascript

Step 4: Create a jQuery script to catch click event from the button and pass parameters to Ajax function and get the result.

 

That’s all! Now we know how to use Ajax in WordPress.

Leave a Reply

Your email address will not be published. Required fields are marked *