Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

How to make ajax work in wordpress

I have been trying to use this ajax form http://blog.teamtreehouse.com/create-ajax-contact-form in wordpress without any success. It works fine in a static html site but in wp the ajax doesn't make its post request. Very frustrated!!!!

Tianni Myers
Tianni Myers
10,453 Points

I skimmed over the link you provided and it doesn’t look like the post was written specifically for WP. WordPress is a CMS not exactly the best place to build a Web Application. I would recommend finding specific documentation for AJAX w/ WP or drop the idea all together.

1 Answer

Could you post a snippet of your code? In theory your code should work, but since you are using it within the context of WordPress' ecosystem, you may have a few additional steps to follow to get it to work. I also disagree that you can't use WP for a web application, as plenty of people have build web apps using it, and it's one of the reasons why the REST API was implemented in core.

Here is an article as well on using AJAX within WordPress:

https://www.smashingmagazine.com/2011/10/how-to-use-ajax-in-wordpress/