We can abstract all the complications away into
an client library though, and fortunately, other people have already done this for us, so we will examine them
next.
4.3 Ajax Client Libraries
Adding the required JavaScript to create an Ajax application used to be quite painful. Even considering the
very simple application above, the checkUsername() function mixes code dealing with the request with code
that knows about how the HTML document is built. This is not good for long term maintenance, as we have
seen in Chapter 2 where we separate concerns using the MVC design pattern for our main application. We
should be separating the responsibilities of our client-side Ajax code too and rather than write all the required
code ourselves, we can utilize an Ajax library to help us.
A JavaScript library will enable us to build upon the work of others. As PHP application developers, we
are often more interested in solving our client??™s problems rather than worrying about the underlying
technology. A JavaScript toolkit library will enable us to work at a higher level with our Ajax in much the
same way that the Zend Framework empowers us in our server side application development.
There are many JavaScript toolkit libraries to choose from and it is not obvious how to make the choice.
Pages:
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130