Introduction to AJAX In WordPress
-
Upload
josh-pollock -
Category
Internet
-
view
563 -
download
3
Transcript of Introduction to AJAX In WordPress
Introduction To AJAX In
WordPressJosh Pollock -- @Josh412 -- JoshPress.net
Who Am I?
What We're Covering Today
https://github.com/Shelob9/introduction-to-ajax
● What Is AJAX?● How It Works In WordPress● Look At Examples● How To Take This Further
PART 1: What Is AJAX?
What Is AJAX?It's Magic!
Remember What This Replaced?
That Is AJAXThat's Awesome
Request Types
Did It Cause The Page To Refresh?
Request - When the client requests data from server.Asynchronous Request - A request that doesn't require a new page load.
Processing
Client-side : Happens in the browser/app.Server-side - Happens on the server.
Server-Side vs Client-Side
PHP vs JavaScript
JavaScript runs client-side*
PHP runs server side.
* This is true enough for today.
An AJAX Request
Client Sends Request
Server Processes RequestServer Responds To Request
Client Receives Response
jQuery AJAX
http://api.jquery.com/category/ajax/
PART 2: How It Works In WordPress
AJAX In WordPress
jQuery GET/POST admin-ajax.php(or other endpoint)
jQuery Callback callback function
AJAX Actions
● wp_ajax_ (logged in users)● wp_ajax_nopriv_ (non-logged in users)
Part 2: EXAMPLE TIME!
Part 3: Further Reading & Questions
● AJAX: The WordPress Developers Handbook
● AJAX Without admin-ajax● Process Forms With AJAX & The REST API● History API● The REST API… All things REST API!
Further Reading
Ask Now, Ask Later
Questions?
Twitter: Josh412WPORG Slack: shelob9Post Status Slack: josh
THANKS!JoshPress.net