Feeds

Xajax and PHP: JavaScript without the pain

Automatic for the people

  • alert
  • submit to reddit

Secure remote control for conventional and virtual desktops

Hands on When it comes to Web 2.0, PHP’s seen it all before. Birthed before the last great internet boom, PHP has matured and is now one of a triumvirate of languages synonymous with today’s craze for building web sites and online services with Linux and MySQL.

While it shares LAMP honors with Perl and Python, though, PHP has become the most commonly used server-side platforms for Ajax and, of all the Ajax frameworks for PHP, Xajax is the most commonly used. If you are not familiar with JavaScript, which forms the basis of Ajax, but still would like to use Ajax with PHP, Xajax is the obvious choice because Xajax generates the required JavaScript for you.

In this Hands On, I’ll demonstrate a simple way to use Ajax and PHP within Xajax, with an Oracle database, while sidestepping the need for the problematic XMLHttpRequest.

Xajax backrounder

Xajax is an open source, object oriented, PHP class library that can be used with PHP scripts for server-side processing. Xajax is used to communicate asynchronously between a client- and a server-side application comprised of PHP scripts, and generates JavaScript wrapper functions so that PHP functions on the server can be accessed from a client application.

When a client application invokes the wrapper functions, a XMLHttpRequest object is initiated and a XMLHttpRequest object is sent to the server. On the server, the Xajax object receives the XMLHttpRequest and invokes the PHP functions corresponding to the JavaScript wrapper functions.

The default request type of PHP functions registered through Xajax is POST. The PHP functions return an XML response that is returned to the client application by the Xajax object. Based on the instructions in the XML response, the Xajax’s JavaScript message pump updates the content of the client input page. Xajax has a feature that, data is updated only if data has been modified.

Download and go

As Xajax is a PHP class library, first download and install PHP 5 and Apache2 HTTP server as explained in an earlier, article on PHP. The example application shall store and fetch data from Oracle database 10g. Therefore, enable the Oracle database extension in the php.ini configuration file.

extension=php_oci8.dll

Create an example database table in OE schema with a PHP script, Table.php, which is available in resources zip. Download Xajax0.2.4/0.2.5. Extract xajax_0.2.4.zip file to the C:/Program Files/Apache Group/Apache2/htdocs directory.

Secure remote control for conventional and virtual desktops

More from The Register

next story
The Return of BSOD: Does ANYONE trust Microsoft patches?
Sysadmins, you're either fighting fires or seen as incompetents now
China hopes home-grown OS will oust Microsoft
Doesn't much like Apple or Google, either
Linux turns 23 and Linus Torvalds celebrates as only he can
No, not with swearing, but by controlling the release cycle
This is how I set about making a fortune with my own startup
Would you leave your well-paid job to chase your dream?
Microsoft cries UNINSTALL in the wake of Blue Screens of Death™
Cache crash causes contained choloric calamity
Eat up Martha! Microsoft slings handwriting recog into OneNote on Android
Freehand input on non-Windows kit for the first time
Linux kernel devs made to finger their dongles before contributing code
Two-factor auth enabled for Kernel.org repositories
prev story

Whitepapers

Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
5 things you didn’t know about cloud backup
IT departments are embracing cloud backup, but there’s a lot you need to know before choosing a service provider. Learn all the critical things you need to know.
Why and how to choose the right cloud vendor
The benefits of cloud-based storage in your processes. Eliminate onsite, disk-based backup and archiving in favor of cloud-based data protection.
Top 8 considerations to enable and simplify mobility
In this whitepaper learn how to successfully add mobile capabilities simply and cost effectively.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?