<?php if (isset($_REQUEST['show_source'])) { highlight_file(__FILE__); exit; } // This file contains only the server side functions and the SANJER require_once "sanjer.php"; $funcArr = array("boomerang"); $sanjer = new SANJER("POST", $funcArr); // Tell SANJER to wait for calls from the client side. $sanjer->start_listening(); // The function that the JS will call. // Notice that one global SANJER object is all you need. // And see how easy it is to put it into a PHP object and back. function boomerang($data) { global $sanjer; $subs = $sanjer->json2object($data); $subs->count++; return $sanjer->object2json($subs); }
<?php if (isset($_REQUEST['show_source'])) { highlight_file(__FILE__); exit; } // That's all you need to include, both for the PHP and the JS require_once "sanjer.php"; // You can pass the PHP functions that AJAX can call // as an array to the constructor. // You can also do it later, using the register() function. $functionArr = array("boomerang"); // create your SANJER PHP object. // Notice "twoFiles2.php", which is where the server side functions are. $sanjer = new SANJER("POST", $functionArr, "twoFiles2.php"); // Notice that in the two file version, the call to start_listening() // is required only in the file that ocntains the server side functions. ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=WINDOWS-1255"> <title>Sajax + JSON test</title> <LINK REL=StyleSheet HREF="sanjer.css" TYPE="text/css" MEDIA=screen> <?php // This function will create all the JS you need to get it to work. $sanjer->show_javascript(); ?> <script type="text/javascript"> function justAddLineBreaks(text){
<?php if (isset($_REQUEST['show_source'])) { highlight_file(__FILE__); exit; } // That's all you need to include, both for the PHP and the JS require_once "sanjer.php"; // You can pass the PHP functions that AJAX can call // as an array to the constructor. // You can also do it later, using the register() function. $functionArr = array("boomerang"); // create your SANJER PHP object. $sanjer = new SANJER("POST", $functionArr); // Set the Debug if needed. // $sanjer->set_debug_mode(true); // Tell the SANJER object to listen to calls from the JS. $sanjer->start_listening(); // Now let's set the function that the JS will call. // Notice that one global SANJER object is all you need. // And see how easy it is to put it into a PHP object and back. function boomerang($data) { global $sanjer; $subs = $sanjer->json2object($data); $subs->count++; return $sanjer->object2json($subs); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">