11.07.2015 Views

AJAX and PHP

AJAX and PHP

AJAX and PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8<strong>AJAX</strong> GridData grids have always been one of the areas where web applications have had a seriousdisadvantage compared to desktop programs. The fact that the page needed a full reload whenswitching between grid pages, or when updating grid details, harmed the application from ausability point of view. Technically, fully reloading the page has bad effects as well, unnecessarilywasting network resources.But now you know there is a smarter solution to this problem. You can use <strong>AJAX</strong> to update thegrid content without refreshing the page. You can keep your beautiful design in the client browserwithout even one page blink. Only the table data is refreshed, not the whole page.The novelty in this chapter is that we'll use Extensible Stylesheet Language Transformation(XSLT) T <strong>and</strong> XML Path Language (XPath) to generate the client output. XSLT <strong>and</strong> XPath arepart of the Extensible Stylesheet Language (XSL) family. XSLT allows defining rules totransform an XML document to another format <strong>and</strong> XPath is a very powerful query language thatallows performing searches <strong>and</strong> retrieving data from XML documents. When used to create webfront ends, XSLT permits implementing a very flexible architecture, in which the server outputsthe data in XML format, <strong>and</strong> that data is transformed to HTML using an XSL transformation. Youcan find an introduction to XSL in Appendix C at http://ajaxphp.packtpub.com, <strong>and</strong> a gooddescription at http://en.wikipedia.org/wiki/Extensible_Stylesheet_Language.Note the XSL transformation can be applied at both client side <strong>and</strong> server side. Theimplementation in this chapter relies on client functionality to perform thetransformation. This doesn't require any special features of the server, but it poses someconstraints for the client. In Chapter 9, you will see how to apply the transformation atthe server side using <strong>PHP</strong> functionality, in which case you require this feature to beenabled in <strong>PHP</strong>, but the solution works with any client, as the client receives directly theHTML code it is supposed to display.In this chapter, you'll use:• XSL to generate an HTML data grid based on XML data received from the server.• <strong>AJAX</strong> to implement the editable data grid. The user should be able to switch betweenproduct pages <strong>and</strong> edit product details without experiencing any page reloads.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!