示例#1
0
$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){
        return text.replace(/(\n)/g, "<br />$1");
    }
	
	function call_remote_php_cb(result) {
    // Again, it's so easy to put the result into a JS object (thanks to JSON)
        var dataReceived = sanjer.json2object(result);
        dataReceived.text = decodeURI(dataReceived.text);
        document.getElementById("result").innerHTML = justAddLineBreaks(dataReceived.text);
        count = dataReceived.count;
        document.getElementById("count").innerHTML = count; 
	}