• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

virusword.com

Learn Wordpress

  • Home
  • WordPress Shop
    • Fotopress
    • SEO Tool Kit
    • Social Contact
    • Tag Machine 2
    • Video Profits
  • Latest News
  • WordPress
    • Plugins
    • Themes
    • Tutorials
    • Videos
    • Woocommerce
  • About Us
  • Contact Us
    • Terms of Service
    • Privacy Policy
  • Show Search
Hide Search
Home/Videos/3 Methods for AJAX in WordPress | Which Method is the Best?

3 Methods for AJAX in WordPress | Which Method is the Best?



In this video, I show you how to use admin-ajax.php, the REST API, and the Rewrite API to make AJAX calls. I also compare the three to see which is the fastest!

Link to the repository: https://github.com/alexander-young/3-ajax-methods

💖 Become a Patron to show support & get perks!
https://www.patreon.com/wpcasts

Sign up for the newsletter. Free course coming in 2020:
https://wpcasts.tv

**SOCIAL**
Twitter: https://twitter.com/AlexanderBYoung
Instagram: https://www.instagram.com/the_alex_young
Facebook: https://www.facebook.com/WPCasts.tv/

#WordPress #AJAX #Development

source

Written by:
Abdul Wahid
Published on:
July 15, 2021

Categories: VideosTags: ajax, ajax in wordpress, ajax tutorial, fetch api, web development, wordpress ajax, wordpress development, wordpress tutorial

Reader Interactions

Comments

  1. WPCasts

    July 15, 2021 at 12:21 am

    I hope you guys learned something! If you want to chat, follow me on Twitter: https://twitter.com/AlexanderBYoung

  2. NAY CHO

    July 15, 2021 at 12:21 am

    Thank you ❤

  3. Attila Balog

    July 15, 2021 at 12:21 am

    Thanks for the great tutorial, have to do some ajax request via admin-ajax, but i keep getting 403 forbidden. Couldn't fix for a day (i'm at work don't have too much time to debug properly).
    The rest-api solution works for me.
    BIG THANK YOU!!!!!

  4. Jitendra

    July 15, 2021 at 12:21 am

    I copied your code in the themes folder and activated but I am still getting 404 errors when I click the submit button because of the routes.. How do I fix that?

  5. Greg Robinson

    July 15, 2021 at 12:21 am

    Great video, thanks! @WPCasts – what's the extension or tool you're using at 11:01 to make the JSON appear neatly formatted and readable? Just curious, thanks.

  6. Annie Dollie

    July 15, 2021 at 12:21 am

    Can you make live search for products with images result? I’m searching for many days but no one teach it

  7. Ez Devv

    July 15, 2021 at 12:21 am

    it makes so much sense to have vs-code tools on the right

  8. Rob Ruiz

    July 15, 2021 at 12:21 am

    Wow…never even heard of the rewrite api for Ajax. Guess I been under a rock. I don't understand regex very well, but seems I need to give it a shot. Never heard of artillery either. Bravo. That's some quality WP developer content. Hats off.

  9. jasp zhy

    July 15, 2021 at 12:21 am

    YES!! I have been using admin-ajax for so long but struggle to understand where does REST API come in, or what Rewrite API does
    this really helped a lot! Thank you!

  10. Khubbaib Naeem

    July 15, 2021 at 12:21 am

    Sorry to say but never use /wp-admin/admin-ajax.php instead localize script using admin_url function so if some change wp-admin directory it will return correct one.

  11. Lorenzo

    July 15, 2021 at 12:21 am

    very good tutorials. !! great job

  12. Rodrigo Chaves

    July 15, 2021 at 12:21 am

    THANK YOU.

  13. Daniel Kowalewski

    July 15, 2021 at 12:21 am

    ….benchmarking using artillery… – o yeah! seatbelt fastened! 😀

  14. Azizul Haque

    July 15, 2021 at 12:21 am

    What do you think of GraphQL? Is it better than all these 3?

  15. Bill Woods

    July 15, 2021 at 12:21 am

    Nice tutorial!!! Good job, I’m a big fan! I have seen you work with the form submission often times, so just out of curiosity, is there any reason that you don’t use “wp-nonce” for the form submission?

  16. Filip Van Reeth

    July 15, 2021 at 12:21 am

    What’s the vscode theme you used 🤪?

  17. žan smolič

    July 15, 2021 at 12:21 am

    I wish there would be a beginner level video to this video, to understand what's you're saying better.

  18. SubbaPdm

    July 15, 2021 at 12:21 am

    please make videos about ajaxing pages (single.php, page.php, archives etc )

  19. Ragnar lodbrok

    July 15, 2021 at 12:21 am

    dude , ur voice like Jonah Hill
    and thanks for tut
    cheers from Egypt!!

  20. manav budhia

    July 15, 2021 at 12:21 am

    Very good tutorial…. really helpful thanks for this great post.
    When you are launching wordpress course ??

  21. Maury Povich

    July 15, 2021 at 12:21 am

    if you do a headless WordPress do you still gotta write PHP code? Just curious how that works since the front-end that's displaying all the data is using javascript and an API.. I'm a jr so still wrapping my head around how things work. Also you seem to be very knowledgable with WP but your title at your job is frontend related, shouldn't you be considered fullstack? By the way thank you for all the content. You are paving your own path with this headless WordPress stuff. It really is the future

  22. ErrorError

    July 15, 2021 at 12:21 am

    TLDR; Rewrite API FTW!

    Fucking awesome video dude, thank you for doing this, very helpful.

  23. Apisit Mhungchomphu

    July 15, 2021 at 12:21 am

    I try to understand what you said because i'm still practice english and i work about wordpress with westerner( Thank you for share your knowledge).

  24. TheMarouuu

    July 15, 2021 at 12:21 am

    42 people forgot to like the video so far. Cmon folks, give this dude some likes.
    Too many beginner videos out there. We need intermediate knowledge like this. For free too!
    Give this dude some support!

  25. Tuấn Trương

    July 15, 2021 at 12:21 am

    Thank you

  26. msv [manikanta srivishnu]

    July 15, 2021 at 12:21 am

    1st like comment…thank u

  27. Олег

    July 23, 2021 at 3:37 am

    AJAX stands for Asynchronous Javascript and XML but very few use XML today and more JSON. However, it is still referred to as AJAX In other words, I have used the wp_localize_script function to create a javascript object and the object is used in the path-to-js-file.js file mentioned in line 6.

Primary Sidebar

Wordpress

  • Content Management Systems (2)
  • Digital Marketing (4)
  • Internet Marketing (28)
  • Latest News (458)
  • Online Business (2)
  • Plugins (519)
  • Themes (521)
  • Videos (1,350)
  • Website Development (1)
  • Woocommerce (589)
  • WordPress (6)

Recent Articles

Unlock Your Internet Marketing Potential with WordPress: Tips, Tools, and Strategies

How to Use WordPress to Achieve Your Internet …

Continue Reading about Unlock Your Internet Marketing Potential with WordPress: Tips, Tools, and Strategies

Unlock Your Internet Marketing Potential: Harnessing the Power of WordPress

How to Use WordPress to Achieve Your Internet …

Continue Reading about Unlock Your Internet Marketing Potential: Harnessing the Power of WordPress

Search our site

Explore more

Get our Wordpress Guide Get Plugins Get Connected

Footer

VirusWord by Promaps, Inc.

Barnes Place
Colombo 7, Western 00700

Copyright © 2025 · Promaps, Inc.

Keep In Touch

  • Email
  • Facebook
  • Instagram
  • Pinterest
  • Twitter