PHPackages                             micropackage/ajax - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. micropackage/ajax

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

micropackage/ajax
=================

Wrapper for WordPress' AJAX

1.0.1(6y ago)1120.0k1GPL-3.0-or-laterPHPPHP &gt;=5.6CI failing

Since Feb 10Pushed 6y ago2 watchersCompare

[ Source](https://github.com/micropackage/ajax)[ Packagist](https://packagist.org/packages/micropackage/ajax)[ RSS](/packages/micropackage-ajax/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Ajax
====

[](#ajax)

[![BracketSpace Micropackage](https://camo.githubusercontent.com/7a9f5ff780f859fdebce60d4e11572de05f86c42ef96b77967c24d7ea7d1e04b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f427261636b657453706163652d4d6963726f7061636b6167652d627269676874677265656e)](https://bracketspace.com)[![Latest Stable Version](https://camo.githubusercontent.com/1fdede3d18bc5836a3a4ea3aa6603fceb64ac03dd2f1363d2e490cd7ab96ced3/68747470733a2f2f706f7365722e707567782e6f72672f6d6963726f7061636b6167652f616a61782f762f737461626c65)](https://packagist.org/packages/micropackage/ajax)[![PHP from Packagist](https://camo.githubusercontent.com/07f7267afcdb3dbf3a1eab7720c8b8d8e0bc1e03a207d6c8823f0ecd061b03fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6963726f7061636b6167652f616a61782e737667)](https://packagist.org/packages/micropackage/ajax)[![Total Downloads](https://camo.githubusercontent.com/90591bcce588bed292d976ec09eb579a5161061ccb29586b19a3d6dc90677d1d/68747470733a2f2f706f7365722e707567782e6f72672f6d6963726f7061636b6167652f616a61782f646f776e6c6f616473)](https://packagist.org/packages/micropackage/ajax)[![License](https://camo.githubusercontent.com/cb34c13ab7710201f0f307a572e70c509f9109be4d4847d387bbe27e30673bc7/68747470733a2f2f706f7365722e707567782e6f72672f6d6963726f7061636b6167652f616a61782f6c6963656e7365)](https://packagist.org/packages/micropackage/ajax)

 [![Micropackage logo](https://camo.githubusercontent.com/9b9fc4f221b3683db4f9cc63e1ed92220004bbda118206d0a26d5ce6377d4d46/68747470733a2f2f627261636b657473706163652e636f6d2f6578747261732f6d6963726f7061636b6167652f6d6963726f7061636b6167652d736d616c6c2e706e67)](https://camo.githubusercontent.com/9b9fc4f221b3683db4f9cc63e1ed92220004bbda118206d0a26d5ce6377d4d46/68747470733a2f2f627261636b657473706163652e636f6d2f6578747261732f6d6963726f7061636b6167652f6d6963726f7061636b6167652d736d616c6c2e706e67)

🧬 About Ajax
------------

[](#-about-ajax)

This micropackage is a wrapper for WordPress AJAX responses in PHP.

💾 Installation
--------------

[](#-installation)

```
composer require micropackage/ajax
```

🕹 Usage
-------

[](#-usage)

### Basic usage

[](#basic-usage)

```
use Micropackage\Ajax\Response;

function ajax_action_handler() {
	$response = new Response();

	// Handle nonce.
	$response->verify_nonce( $action = 'my_action', $query_arg = 'noncefield', $send_if_failed = true );

	// Do some checks and immediately send an error.
	if ( something_is_wrong() ) {
		$response->error( 'Error message' );
	}

	// This is never reached.
	$response->send( 'All good' );

}
```

### Error collecting

[](#error-collecting)

You can collect multiple errors in one response.

```
use Micropackage\Ajax\Response;

function ajax_action_handler() {
	$response = new Response();

	// Do some checks.
	if ( something_is_wrong() ) {
		$response->add_error( 'Error message' );
	}

	// Do some checks.
	if ( something_else_is_wrong() ) {
		$response->add_error( 'Whoah!' );
	}

	// If no error added, the below message will be sent.
	$response->send( 'All good if no errors' );

}
```

### Sending data

[](#sending-data)

```
use Micropackage\Ajax\Response;

function ajax_action_handler() {
	$response = new Response();
	$response->send( $data_array );
}
```

📦 About the Micropackage project
--------------------------------

[](#-about-the-micropackage-project)

Micropackages - as the name suggests - are micro packages with a tiny bit of reusable code, helpful particularly in WordPress development.

The aim is to have multiple packages which can be put together to create something bigger by defining only the structure.

Micropackages are maintained by [BracketSpace](https://bracketspace.com).

📖 Changelog
-----------

[](#-changelog)

[See the changelog file](./CHANGELOG.md).

📃 License
---------

[](#-license)

GNU General Public License (GPL) v3.0. See the [LICENSE](./LICENSE) file for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2289d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd1fdcaa145bfe7d6d015951da54a856f34988c581ae5a2de4c9df6d3b696ebc?d=identicon)[kubitomakita](/maintainers/kubitomakita)

---

Top Contributors

[![jakubmikita](https://avatars.githubusercontent.com/u/18362490?v=4)](https://github.com/jakubmikita "jakubmikita (10 commits)")

---

Tags

ajaxbracketspacemicropackagephpwordpresswrapper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/micropackage-ajax/health.svg)

```
[![Health](https://phpackages.com/badges/micropackage-ajax/health.svg)](https://phpackages.com/packages/micropackage-ajax)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
