Feeds

Xajax and PHP: JavaScript without the pain

Automatic for the people

  • alert
  • submit to reddit

Intelligent flash storage arrays

Also specify in the tags of the input form that Xajax should generate any required JavaScript after an XML response has been sent back from the server.

<?php $xajax->printJavascript('./xajax');
?>

A XMLHttpRequest is initiated by a client application. In the example application, a XMLHttpRequest is initiated by the onkeyup event handler in input field catalogId.

<tr><td>Catalog Id:</td><td><input    type="text"
            size="20"  
              id="catalogId"
            name="catalogId"
    autocomplete="off"
         onkeyup="xajax_validateCatalogId(xajax.getFormValues('validationForm'));"></td>
         <td><div id="validationMessage"></div></td>
</tr>

The input field invokes the wrapper function xajax_validateCatalog with an array of form field values as a parameter. The wrapper functions send a XMLHttpReques to the server. The xajaxobject receives the XMLHttpRequest and invokes the corresponding PHP function validateCatalogId($formValues).

Process an Ajax request

Xajax provides the xajaxResponseclass to send a response to the client application. In the validateCatalogId function, create a xajaxResponse object.

$objResponse = new xajaxResponse();

The validateCatalogId function validates a Catalog Id value added in the input form. From the $formValues array retrieve the value of the catalogId field.

$catalogId=trim($formValues['catalogId']); 

Next, use the PHP Oracle extension to connect with the Oracle database and determine if a Catalog table row is defined for the catalog id value input in the input form. If the result set is empty, a Catalog table row for the catalog id value is not defined in the database table. Therefore, the Catalog Id field value added in the form is valid.

Next, we shall generate a response to be sent to the client application. A response contains one or more command messages. Some of the commonly used command messages are discussed in table below.

Command Message Description
Assign Sets the specified attribute of an element in input page with method addAssign().
Append Appends data to the specified attribute of an element in the input page with method addAppend().
Prepend Prepends data to the specified attribute of an element in the input page with method addPrepend().
Replace Replaces data in the specified attribute of an element in the input page with method addReplace().
Script Runs the specified JavaScript code with method addScript().
Alert Displays an alert box with the specified message with method addAlert().

Providing a secure and efficient Helpdesk

More from The Register

next story
UNIX greybeards threaten Debian fork over systemd plan
'Veteran Unix Admins' fear desktop emphasis is betraying open source
Netscape Navigator - the browser that started it all - turns 20
It was 20 years ago today, Marc Andreeesen taught the band to play
Redmond top man Satya Nadella: 'Microsoft LOVES Linux'
Open-source 'love' fairly runneth over at cloud event
Google+ goes TITSUP. But WHO knew? How long? Anyone ... Hello ...
Wobbly Gmail, Contacts, Calendar on the other hand ...
Chrome 38's new HTML tag support makes fatties FIT and SKINNIER
First browser to protect networks' bandwith using official spec
Admins! Never mind POODLE, there're NEW OpenSSL bugs to splat
Four new patches for open-source crypto libraries
prev story

Whitepapers

Forging a new future with identity relationship management
Learn about ForgeRock's next generation IRM platform and how it is designed to empower CEOS's and enterprises to engage with consumers.
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.
Three 1TB solid state scorchers up for grabs
Big SSDs can be expensive but think big and think free because you could be the lucky winner of one of three 1TB Samsung SSD 840 EVO drives that we’re giving away worth over £300 apiece.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.