Location: PHPKode > scripts > J4P micro ajax > index.php
<?php

// Include J4P.
require_once "lib/j4p/J4P.php";

// This function can be used in Javascript:
// phpSync('parseForm', string); 
function j4p_parseForm($input)
{
	parse_str($input, $formData);
	
	$bgColor = "#" . rand(555555, 999999);
	
	J4P::addResponse()->document->getElementById("output")->innerHTML = print_r($formData, true);
	J4P::addResponse()->jQuery("body")->css("background-color", $bgColor);
	J4P::addResponse()->alert("New bgColor: $bgColor");
}

?><!DOCTYPE html>
<html>
	<head>
		<title>J4P Demo</title>
		<meta charset="utf-8">
		<!-- Needed Javascript include for J4P -->
		<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
		<?php J4P::outputJs(0); ?>
	</head>
	<body>
		<form name="myForm" id="myForm">
			<input name="someInputField" value="someValue" />
			&nbsp;
			<input type="button" value="Synchronous ajax call"
				onclick="php('sync', 'parseForm', $('#myForm').serialize());" />
			&nbsp;
			<input type="button" value="Asynchronous ajax call"
				onclick="php('async', 'parseForm', $('#myForm').serialize());" />
		</form>
		<div><pre id="output"></pre></div>
	</body>
</html>
Return current item: J4P micro ajax