- jQuery 1.3 with PHP
- Kae Verens
- 796字
- 2021-04-01 13:36:00
Chapter 2. Quick Tricks
PHP programmers can be tempted to consider only the server side of the website equation and leave the client side to the designer. Your job, as a PHP developer, is to make sure that the requested actions happen efficiently, and this does not appear to be a client-side problem.
When a customer expresses that the site doesn't look very modern or snappy, as a server-side developer, it is tempting to think that this is a problem for the designers, as they have traditionally had most of the control about what is sent to the client, and you have traditionally only been asked to supply an HTML skeleton for them to wrap the design around.
However, more and more code these days is shifting onto the client side of the transaction. And as a result, developers are taking a stronger interest in how they can affect data on the client side, and how they can help the designer to make an impact.
There are reasons why you, as a developer, should be interested in what happens on the client side. Using tricks such as Ajax and client-side form validation, you can relieve the strain on bandwidth and the server's resources, and at the same time, increase the responsiveness and usability of the application.
What happens on the client side does affect the server side. It is optimizing of this overlap, and not heavy and centralized architectures, that can help your own application scale with more ease.
And that's partly what's different about PHP/HTML versus PHP/HTML/jQuery. In the old PHP/HTML architecture, we had a very clear distinction, where data was calculated and turned into HTML on the server, and the client was used just for displaying that data exactly as the server rendered it. However, we are now at a point where we can use the power of client-side technologies, such as jQuery, to do part of the rendering on the client.
This allows your systems to grow easily, but it also allows your clients to have more control over how the data is rendered on the screen. With PHP and jQuery, your users will learn how quick and tactile their interfaces are, your marketers will love the "wow factor" that happens when they show the system to new customers, and your administrators will love you for relieving the burden on the server that classic "web 1.0" methods impose.
As PHP is used at the server side and jQuery at the client side, this book will show you a lot of tricks to help the interaction between the two. This is not a book about Ajax, as it is important that you don't concentrate on the data transfer part of it—instead, we'll concentrate on the jQuery and PHP part of it, and the Ajax part of it will be treated as a simple consequence of what we are doing.
jQuery makes Ajax almost invisible; in fact, it is so simple to use that after a while, you completely forget that what you are doing is something that could not be done easily even just four years ago. This is fantastic, as it allows us to combine the server side with the client side as if they are literally speaking to each other.
To start off, I'll show you a few tricks, which demonstrate how to relieve some more obvious resource wastes.
The examples discussed are the common patterns that you will have seen being used online or in desktop applications.
- Dynamically populated select boxes, where changing one select box changes the options available in the other select box
- Quick deletes, where deleting an object deletes it immediately from the view instead of waiting till a page has been reloaded, helping the site to appear responsive
- Contextual help, where help can be obtained about an object by simply turning help on, and then clicking an icon near the object
- Inline editing, where a table's data can be edited immediately, instead of needing to load a special forms page to edit it
In Chapter 1, Introduction and Overview, I described the example directory layout that will be used throughout the book.
To recap, here is the layout that I used while writing the following examples:
http://yoursite.xyz/jquery.min.js http://yoursite.xyz/2-contextual_help/ http://yoursite.xyz/2-dynamic_select_boxes/ http://yoursite.xyz/2-inline_editing/ http://yoursite.xyz/2-quick_deletes/
When starting a new example, you should create a new directory. If the book says "create a file, xyz.html
", then the file is created in that new directory.
In all the examples of this book, the library files, including jquery.js
and all others we use, will be kept in the root of the examples, while the example files will be kept in their own separate directories.
This allows us to write new example files without needing to always download the library files.
- Excel函數(shù)、公式、圖表、數(shù)據(jù)處理從新手到高手
- Microsoft Forefront UAG 2010 Administrator's Handbook
- AutoCAD 2018實用教程(第5版)
- Authorware應用案例教程
- 中文版CorelDRAW X6基礎培訓教程
- 零基礎學后期:Photoshop+Lightroom數(shù)碼照片處理從新手到高手
- AutoCAD 2016中文版完全自學手冊
- SOA Patterns with BizTalk Server 2009
- CAXA電子圖板2016基礎與實例教程
- UG NX 9中文版從入門到精通
- Photoshop插畫藝術(shù)火星風暴
- 巧學巧用Flash CS6制作動畫
- 中文版Photoshop CS6應用技法教程
- Photoshop移動UI設計從入門到精通
- Photoshop CS6數(shù)碼照片處理入門到精通