Instant Actions

From Wikipedia, the free encyclopedia

Instant Actions is a Simple PHP Object that can be integrated easily by developers in their own applications.

It allows developers to call PHP functions from JavaScript through AJAX.

[edit] Timeline

It was published on the 5th of January 2003 by Thomas Christian, and its core was based on the already existing Sajax Class. In 2005 the Instant Actions Object was rebuild on its own Core Class.

Recently the Instant Actions Object was included in the Base Framework Project in 2007

[edit] Examples

The PHP Part would look like this:
<?php

include_once('instant_actions.class.php');

function func1($param1, $param2) { return 'func1 with param1: '.$param1.' and param2: '.$param2; }

function func2() { return true; }

$ia=new InstantActions ;
$ia->initiate(); // Initiates the base object in JavaScript
$exports=$ia->export('func1', 'func2'); // Exports functions that can be executed form JavaScript through AJAX
$ia->handle_client_request();

?>

The HTML Part would look like this:
<?php $ia->include_javascript(); ?>
<form name="frm_ia" action="<?php echo InstantActions::get_uri(); ?>" method="post" ia:import="$exports">
<input type="button" value="call func1" onclick="alert(php.$exports.func1()); /* or alert(php.func1()); */" >
</form>