introduction to ajax in wordpress

Post on 03-Aug-2015

563 Views

Category:

Internet

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

Ask Now, Ask Later

Questions?

Twitter: Josh412WPORG Slack: shelob9Post Status Slack: josh

THANKS!JoshPress.net

top related