J4P micro ajax

J4P micro ajax bringt mit einer sehr kleinen Dateigröße umfangreiche Javascript Funktionalität in Deine PHP Anwendung.
Wenn Du Javascript kennst, wirst Du J4P micro ajax lieben. Du kannst auch einen großen Teil der jQuery Bibliothek in Deinem PHP Code verwenden.

BeispielDownloadImpressumEnglish

Beispiel

<?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.

Ich habe die Lizenzvereinbarung gelesen, verstanden und akzeptiere diese.

Download J4P.php (1.1.0)


Alle Handelsnamen, Firmennamen, Produktnamen und Logos sind Warenzeichen
oder eingetragene Warenzeichen ihrer jeweiligen Besitzer.
© 2013 by Peter Pippinger. Alle Rechte vorbehalten.