note 79242 added to faq.html
| From: | Anonymous at osu1 dot php dot net | Date: | Fri, 16 Nov 2007 18:15:38 +0000 |
| Subject: | note 79242 added to faq.html | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132359@lists.php.net to get a copy of this message | ||
xajaxproject.org has developed a PHP class that lets you integrate javaScript and PHP completely.
It's original purpose was to provide an easy way for PHP programmers with poor javaScript to
use ajax.
You can run javascript functions from within PHP functions and trigger and return PHP functions from
javascript. It also takes about 10-30 minutes to learn how to set up the page and use.
In this example the div content is hard coded but it could be taken from a database and presented on
the page without the need for a refresh.
<?
require ('../xajax/xajax.inc.php');
$xajax = new xajax();
//$xajax->debugOn();
//xajax version 0.24
function contentone() {
$objResponse = new xajaxResponse();
ob_start();
echo "Lorem ipsum dolor ";
$objResponse->addAssign('content', 'innerHTML', ob_get_clean());
return $objResponse;
}
$xajax->registerFunction("contentone");
function contenttwo() {
$objResponse = new xajaxResponse();
ob_start();
echo "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum eleifend, eros
ac pharetra mattis, sem sem fermentum mauris, in viverra odio nunc id magna. Nullam augue.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi
consectetuer lacinia nisl. Duis sem mauris, vestibulum mollis, varius non, vulputate vel, pede. Ut
felis nisl, commodo vitae, luctus sed, tempus facilisis, mauris. Cras ut urna. Nullam diam libero,
condimentum quis, dictum a, ullamcorper vitae, nulla. Fusce eros lacus, condimentum et, vulputate
id, ultricies vel, lorem. Vivamus tristique dolor in massa. Aliquam erat volutpat. Nam quis risus.
Quisque sed metus.";
$objResponse->addAssign('content', 'innerHTML', ob_get_clean());
return $objResponse;
}
$xajax->registerFunction("contenttwo");
$xajax->processRequests();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE> xAjax Expanding Div Height with Content</TITLE>
<style type="text/css">
body, dd, dl, dt, html, div, ol, ul, li, h1, h2, h3, h4, h5, img, a, a:active, a:hover, a:visited {
margin:0px; padding:0px; font-family: arial,helvetica, sans-serif;
}
div#content {
margin:20px;
padding:5px;
border: 1px solid black;
width:200px;
font: normal 12px arial;
min-height:150px;
height:auto !important;
height:150px;
}
</style>
<?
$xajax->printJavascript('../xajax/');
?>
</HEAD>
<BODY>
<p><a href="#" onclick="xajax_contentone(); return
false;">one</a></p>
<p><a href="#" onclick="xajax_contenttwo(); return
false;">two</a></p>
<div id="content">
</div>
<script type="text/javascript">
<!--
xajax_contentone()
//-->
</script>
<p><a href="expandingdiv.zip">file</a></p>
</BODY>
</HTML>
----
Server IP: 69.147.83.197
Probable Submitter: 209.194.189.187
----
Manual Page -- http://www.php.net/manual/en/faq.html.php
Edit -- https://master.php.net/note/edit/79242
Del: integrated -- https://master.php.net/note/delete/79242/integrated
Del: useless -- https://master.php.net/note/delete/79242/useless
Del: bad code -- https://master.php.net/note/delete/79242/bad+code
Del: spam -- https://master.php.net/note/delete/79242/spam
Del: non-english -- https://master.php.net/note/delete/79242/non-english
Del: in docs -- https://master.php.net/note/delete/79242/in+docs
Del: other reasons-- https://master.php.net/note/delete/79242
Reject -- https://master.php.net/note/reject/79242
Search -- https://master.php.net/manage/user-notes.php