J4P micro ajax

J4P micro ajax in a simple way brings extensive ajax functionality in PHP applications at a minimum of size.
If you know javascript you will love J4P micro ajax. You also can use a wide range of the jQuery library on PHP side.

ExampleDownloadSite noticeDeutsch

Example

<?php

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

// This php function can be used in javascript.
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>

Download

MIT License (MIT)

Copyright (c) 2013 Peter Pippinger

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

I have read the license agreement and accept these.

Download J4P.php (1.1.0)


All trade names, company names, product names and logos
are registered trade marks of their respective owners.
© 2013 by Peter Pippinger. All rights reserved.