Skip to content

[DevHub] Plugin Handbook AJAX doc does not mention or use the REST API #347

@tomjn

Description

@tomjn

Issue Description

The document that describes how to use AJAX in WordPress only refers to the old admin AJAX API, and not only doesn't describe AJAX with the REST API, but doesn't mention its existence. The REST API is a surprise for most users trying to debug AJAX, even though debugging with the REST API gives you human readable error messages where Admin AJAX prints 0

URL of the Page with the Issue

https://developer.wordpress.org/plugins/javascript/ajax/

Section of Page with the issue

Entire page

Why is this a problem?

While we shouldn't be encouraging the use of an older more difficult API, we should at the very least mention that a newer API exists

Suggested Fix

One of the following:

  1. mention the REST API at the top and note that the document talks about admin-ajax.php which is an older API
  2. rewrite the doc to work the same way but with a REST API endpoint via register_rest_route
  3. add both REST API and Admin AJAX API examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    developer documentation (DevHub)Improvements or additions to developer documentationpluginsIssues for Plugin Developer Handbook

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions