Feeds

Xajax and PHP: JavaScript without the pain

Automatic for the people

  • alert
  • submit to reddit

Secure remote control for conventional and virtual desktops

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().

Top 5 reasons to deploy VMware with Tegile

More from The Register

next story
Google+ goes TITSUP. But WHO knew? How long? Anyone ... Hello ...
Wobbly Gmail, Contacts, Calendar on the other hand ...
Preview redux: Microsoft ships new Windows 10 build with 7,000 changes
Latest bleeding-edge bits borrow Action Center from Windows Phone
Google opens Inbox – email for people too thick to handle email
Print this article out and give it to someone tech-y if you get stuck
Microsoft promises Windows 10 will mean two-factor auth for all
Sneak peek at security features Redmond's baking into new OS
UNIX greybeards threaten Debian fork over systemd plan
'Veteran Unix Admins' fear desktop emphasis is betraying open source
DEATH by PowerPoint: Microsoft warns of 0-day attack hidden in slides
Might put out patch in update, might chuck it out sooner
Redmond top man Satya Nadella: 'Microsoft LOVES Linux'
Open-source 'love' fairly runneth over at cloud event
prev story

Whitepapers

Cloud and hybrid-cloud data protection for VMware
Learn how quick and easy it is to configure backups and perform restores for VMware environments.
A strategic approach to identity relationship management
ForgeRock commissioned Forrester to evaluate companies’ IAM practices and requirements when it comes to customer-facing scenarios versus employee-facing ones.
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?
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.
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.