THE AJAX APPROACH TO BROWSER SCRIPTING in Font

Creator DataMatrix in Font THE AJAX APPROACH TO BROWSER SCRIPTING

CHAPTER 9 THE AJAX APPROACH TO BROWSER SCRIPTING
Data Matrix ECC200 Drawer In None
Using Barcode creation for Font Control to generate, create Data Matrix ECC200 image in Font applications.
www.OnBarcode.com
PDF417 Generator In None
Using Barcode maker for Font Control to generate, create PDF417 image in Font applications.
www.OnBarcode.com
<tr> <th>Name</th> <th>Type</th> </tr> <xsl:apply-templates select="/contacts/person"> <xsl:sort select="last_name" order="ascending"/> </xsl:apply-templates> </table> </div> </xsl:template> <xsl:template match="person"> <tr> <td><a href="javascript:showPerson({@id});"> <xsl:value-of select="first_name"/><xsl:text> </xsl:text> <xsl:value-of select="last_name"/> </a></td> <td><xsl:value-of select="@type"/></td> </tr> </xsl:template> </xsl:stylesheet> The main difference here is that I ve applied a sort order to the contacts they are sorted by ascending last name. The example also displays the contacts in a table within a <div> element. I ve linked the name so that the user can click it to display the details of the selected person. When the user selects a person, the link calls the showPerson() function. This function receives the contact s id in the parameter intPersonID: function showPerson(intPersonID) { var url = "contacts" + intPersonID + ".xml"; sendRequest(url, 'details.xslt', xmlDetailsReady, xslDetailsReady); } The showPerson() function builds the XML document name and calls the sendRequest() function, passing in parameters for the new XML document and the details.xslt stylesheet. It also sets the two event handler functions. These event handlers are similar to the functions you saw earlier: function xmlDetailsReady() { if (xmlhttp.readyState==4){ if (xmlhttp.status==200) { xmlDetails = xmlhttp.responseXML; doTransform("displayDetails", xmlDetails, xslDetails); } } } function xslDetailsReady() { if (xslhttp.readyState==4){ if (xslhttp.status==200) {
Encoding European Article Number 13 In None
Using Barcode printer for Font Control to generate, create EAN-13 Supplement 5 image in Font applications.
www.OnBarcode.com
Code 128 Code Set B Maker In None
Using Barcode maker for Font Control to generate, create USS Code 128 image in Font applications.
www.OnBarcode.com
CHAPTER 9 THE AJAX APPROACH TO BROWSER SCRIPTING
Painting Data Matrix ECC200 In None
Using Barcode encoder for Font Control to generate, create Data Matrix ECC200 image in Font applications.
www.OnBarcode.com
Paint Barcode In None
Using Barcode creator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
xslDetails = xslhttp.responseXML; doTransform("displayDetails", xmlDetails, xslDetails); } } } The event handler functions call the doTransform() function, passing in the name of the display element and the two documents. The function transforms the XML details using the details.xslt stylesheet. This stylesheet is similar to the one from 8: < xml version="1.0" encoding="UTF-8" > <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <div> <xsl:apply-templates select="/contacts/person"/> </div> </xsl:template> <xsl:template match="person"> <p><span class="emphasis">Name: </span> <xsl:value-of select="first_name"/> <xsl:text> </xsl:text> <xsl:value-of select="last_name"/></p> <p><span class="emphasis">Type: </span> <xsl:value-of select="@type"/></p> <p><span class="emphasis">Company: </span><xsl:value-of select="company"/></p> <p><span class="emphasis">Address: </span> <xsl:value-of select="address1"/>, <xsl:value-of select="address2"/>, <xsl:value-of select="country"/> <xsl:text> </xsl:text> <xsl:value-of select="postal_code"/></p> </xsl:template> </xsl:stylesheet> Notice that I ve added some structure and styling information. For example, I ve included a reference to the emphasis class, which highlights the titles. As I mentioned earlier, the style declarations are embedded in the XHTML page. In the previous two examples, I had to branch the code to respond to the differences between web browsers. An alternative is to use across-browser library.
QR Code ISO/IEC18004 Maker In None
Using Barcode drawer for Font Control to generate, create Denso QR Bar Code image in Font applications.
www.OnBarcode.com
USPS POSTal Numeric Encoding Technique Barcode Creator In None
Using Barcode encoder for Font Control to generate, create Delivery Point Barcode (DPBC) image in Font applications.
www.OnBarcode.com
Using Cross-Browser Libraries
ECC200 Decoder In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Draw Data Matrix 2d Barcode In None
Using Barcode maker for Word Control to generate, create Data Matrix image in Office Word applications.
www.OnBarcode.com
As you saw in the previous section, you must address a number of cross-browser issues when writing Ajax applications. You need to create the XMLHttpRequest object using ActiveX in IE, whereas it s a native object in Mozilla and Opera. You also need to apply XSLT transformations differently depending on the browser.
PDF417 Creation In None
Using Barcode creator for Online Control to generate, create PDF417 image in Online applications.
www.OnBarcode.com
Recognize Data Matrix 2d Barcode In .NET Framework
Using Barcode reader for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
CHAPTER 9 THE AJAX APPROACH TO BROWSER SCRIPTING
Painting Data Matrix 2d Barcode In C#.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create DataMatrix image in VS .NET applications.
www.OnBarcode.com
Print Barcode In None
Using Barcode maker for Office Word Control to generate, create Barcode image in Microsoft Word applications.
www.OnBarcode.com
Using a library is one solution to creating cross-browser Ajax applications. In this section, I ll look at the Sarissa library.
Print Data Matrix ECC200 In Java
Using Barcode drawer for Android Control to generate, create Data Matrix ECC200 image in Android applications.
www.OnBarcode.com
Barcode Generation In VS .NET
Using Barcode maker for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
Sarissa
Paint PDF 417 In VB.NET
Using Barcode generator for VS .NET Control to generate, create PDF417 image in .NET framework applications.
www.OnBarcode.com
DataMatrix Printer In None
Using Barcode creator for Online Control to generate, create Data Matrix ECC200 image in Online applications.
www.OnBarcode.com
Sarissa is a cross-browser JavaScript library that works with XML manipulation. You can use the basic functionality with IE, Mozilla, Opera, and Safari. Bear in mind, though, that the XSLT features won t work with Opera 8.5 and below. Sarissa uses function calls that are similar to the native XMLHttpRequest object: var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = processXML; xmlhttp.open("GET", "dvd.xml", true); xmlhttp.send(null); function processXML(){ if(xmlhttp.readyState == 4){ alert(xmlhttp.responseXML); } } It mimics the XSLTProcessor object to manipulate stylesheets in IE, and you can use Sarissa for other tasks such as creating a DOM Document: var oDomDoc = Sarissa.getDomDocument(); oDomDoc.onreadystatechange = processXML; oDomDoc.load("dvd.xml"); function processXML { if(oDomDoc.readyState == 4) alert(Sarissa.serialize(oDomDoc)); } } To get started with Sarissa, you need to download the library from http:// sourceforge.net/projects/sarissa. You ll see how it works by revisiting the contacts example. You can find the files in the contacts_Sarissa folder. I ll walk through this example so you can see how the use of the Sarissa wrapper streamlines the code. You ll notice that the resource folder includes the sarissa.js and sarissa_ieemu_xslt.js files. The first file includes the core functionality for Sarissa, while the second provides the XSLT functionality for IE. The page contacts_Sarissa_AJAX_demo.htm hosts the application and includes the following lines: <script type="text/javascript" src="sarissa.js"></script> <script type="text/javascript" src="sarissa_ieemu_xslt.js"></script>
Barcode Creation In VS .NET
Using Barcode creator for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
GS1 - 13 Maker In None
Using Barcode creation for Online Control to generate, create EAN-13 Supplement 5 image in Online applications.
www.OnBarcode.com
Copyright © OnBarcode.com . All rights reserved.