introduction to ajax in wordpress

20
Introduction To AJAX In WordPress Josh Pollock -- @Josh412 -- JoshPress.net

Upload: josh-pollock

Post on 03-Aug-2015

570 views

Category:

Internet


3 download

TRANSCRIPT

Page 1: Introduction to AJAX In WordPress

Introduction To AJAX In

WordPressJosh Pollock -- @Josh412 -- JoshPress.net

Page 2: Introduction to AJAX In WordPress

Who Am I?

Page 3: Introduction to AJAX In WordPress

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

Page 4: Introduction to AJAX In WordPress

PART 1: What Is AJAX?

Page 5: Introduction to AJAX In WordPress

What Is AJAX?It's Magic!

Page 6: Introduction to AJAX In WordPress

Remember What This Replaced?

Page 7: Introduction to AJAX In WordPress

That Is AJAXThat's Awesome

Page 8: Introduction to AJAX In WordPress

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.

Page 9: Introduction to AJAX In WordPress

Processing

Client-side : Happens in the browser/app.Server-side - Happens on the server.

Server-Side vs Client-Side

Page 10: Introduction to AJAX In WordPress

PHP vs JavaScript

JavaScript runs client-side*

PHP runs server side.

* This is true enough for today.

Page 11: Introduction to AJAX In WordPress

An AJAX Request

Client Sends Request

Server Processes RequestServer Responds To Request

Client Receives Response

Page 12: Introduction to AJAX In WordPress

jQuery AJAX

http://api.jquery.com/category/ajax/

Page 13: Introduction to AJAX In WordPress

PART 2: How It Works In WordPress

Page 14: Introduction to AJAX In WordPress

AJAX In WordPress

jQuery GET/POST admin-ajax.php(or other endpoint)

jQuery Callback callback function

Page 15: Introduction to AJAX In WordPress

AJAX Actions

● wp_ajax_ (logged in users)● wp_ajax_nopriv_ (non-logged in users)

Page 16: Introduction to AJAX In WordPress

Part 2: EXAMPLE TIME!

Page 17: Introduction to AJAX In WordPress

Part 3: Further Reading & Questions

Page 19: Introduction to AJAX In WordPress

Ask Now, Ask Later

Questions?

Twitter: Josh412WPORG Slack: shelob9Post Status Slack: josh

Page 20: Introduction to AJAX In WordPress

THANKS!JoshPress.net