This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.



Provides an easy way for plugin/theme developers to use Xajax framework to write ajax applications.


For an overview on how to use XAjax and complete documentation, visit its wiki at

Here you find a very pratical tutorial on how to write a wordpress plugin using xajax. This tutorial is based on the great “Learn xaja in 10 minutes”, wich you find here:

How to write a plugin using wp-xajax.

  1. Install wp-xajax

Obviusly you have to install it at first. Nothing will happen when you activate it, thats the way it is.

  1. Write your php function

Now, inside your plugin, you will write you php function that will be dinamically called through javascript.

This function can do anything you like: access the database, send emails, call other functions.. whatever.

The only thing this function can not do is to produce any output to the screen. It cannot have any “echo” calls.

In the next step we will see how to send output to the screen. So, lets say we want a function to send an email:

function myplugin_sendEmail(){

$friends = ',';
mail($friends, "blog updated", 
  'I just put something on my blog:');


This function does not receive any argumnent, but you can have a function that receives as many argumnents as you like.

  1. Add some response to your function

Lets say you have a div next to your button with the id “response_div”. Then you can add this to you function:

function myplugin_sendEmail(){

$friends = ',';
mail($friends, "blog updated", 
  'I just put something on my blog:');

$objResponse = new xajaxResponse();
$objResponse->addAssign("response_div","innerHTML","Email Sent!");
return $objResponse;


You will allways interact with the page objects using their ids. There are many ways in wich you can interact, have a look at
the full doc here:

  1. Call your function

A javascript function will be created. It will be called xajax_YourFunctionName.

So you may have a button, and add to this button the event Handler:

input type=”button” onclick=”xajax_myplugin_sendEmail()”;

if you have any arguments to pass, do it now as if it was a regular javascript function.

  1. Register your function

Create a function that will register your xajax_function as follow:

function myplugin_xajax(){
gobal $xajax;

And then add an action to call it:


  1. Enjoy!


1.0 (06/06/2008)
. Released

Contributors & Developers

This is open source software. The following people have contributed to this plugin.


Browse the code