Xajax 0.2: Tips and Tricks: Firefox (Mozilla)
Xajax 0.2: Tips and Tricks: Firefox (Mozilla)
xajax helps the PHP developer to write AJAX without bothering with Javascript on the server side. But what about the client side?
Firefox (or other Mozilla programs) allows for the writing of applications (and their distribution) with the fairly simple XUL (just an XML mark-up, similar to HTML), CSS (for styling), and Javascript (here generated by xajax (in PHP)). These applications, though they can only be used within Mozilla-based browsers, allow for control of the whole interface of the browser, and when run locally give the potential for access to the filesystem (i.e., for locally stored data).
Unfortunately, there is no PHP plugin for Firefox, so the only way this could be used locally would be to have PHP installed. (Even then, would the access be privileged?) However, one might find it handy to use xajax to write the Javascript/XUL code which could then be ported into an extension. However, such scripts would be limited in that one could not write the code to access the client's filesystem in this manner (?) (though one could of course use xajax to write AJAX that could be used within a local XUL file to access remote data (see also the Related Links section below)).
The following is a sample file included with the xajax documentation:
<?php
// xulApplication.php demonstrates a XUL application with xajax
// XUL will only work in Mozilla based browsers like Firefox
// using xajax version 0.2
// http://xajaxproject.org
require_once("../../xajax.inc.php");
function test() {
$objResponse = new xajaxResponse();
$objResponse->addAlert("hallo");
$objResponse->addAssign('testButton','label','Success!');
return $objResponse->getXML();
}
$xajax = new xajax();
$xajax->registerFunction("test");
$xajax->processRequests();
header("Content-Type: application/vnd.mozilla.xul+xml");
?>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="example-window" title="Exemple 2.2.1"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
var xajaxRequestUri="xulServer.php";
var xajaxDebug=false;
var xajaxStatusMessages=false;
var xajaxDefinedGet=0;
var xajaxDefinedPost=1;
</script>
<script type="application/x-javascript" src="../../xajax_js/xajax.js"></script>
<button id="testButton" oncommand="xajax.call('test',[]);" label="Test" />
</window>
[edit] Related links
- http://www.phppatterns.com/docs/develop/connecting_xul_applications_with_php - Describes how to write Javascript to connect (on the client side) to a PHP (server) application