Enhancing PHP Via the ASP.NET AJAX Framework: A Second Look - Code Examination
(Page 2 of 4 )
First of all, under the new PHP environment, it's impossible for us to fall back on the ASP.NET AJAX server-side control-ScriptManager. We have no choice but to refer to the ASP.NET AJAX client-side scripts and the formerly-defined PHP web service via manually programming them.
Second of all, please pay attention to the following line:
<script type="text/javascript"
src=" AnimalService.php/js"></script>
Herein, we must append a /js suffix to the PHP file in which the custom web service class is defined. This will notify the web server to tell the relevant PHP code and, with the help of Microsoft AJAX Library, to generate the appropriate client-side proxy for the PHP-styled web service and download it to the browser.
As a matter of fact, you can enter the above /js-suffixed line of code directly to the address bar of your browser and press ENTER to watch the interesting client-side proxy for the web service, which is shown in Figure 4.
Figure 4-the automatically generated web service proxy on the client side
_html_m6de9b6db.png)
Examine this carefully and you will find out that the client-side proxy is quite similar to those generated and discussed under the ASP.NET environment. And since our main interests do not lie herein, we will not dwell on it.
Next, notice that for a rather typical sample we painstakingly introduced one of the ASP.NET AJAX Futures CTP (the newest name is called 'ASP.NET Futures') scripts-PreviewScript.debug.js (you can use the release version, PreviewScript.js, instead of the debug version).
According to my shallow study, you can leverage most of the code inside PreviewScript.debug.js. However, there is apparently one deficiency in PHP for Microsoft AJAX Library (currently still in its '3 Alpha' version): we can not utilize the 'great' DataSource component as in the ASP.NET scenario. To some degree, we can say that the DataSource component is a marvelous invention under the ASP.NET environment that greatly simplifies the client-side data binding to the corresponding server side.
What we need to do is refer to a DataSource component in the xml-script programming and configure a few parameters. Then the client-side ListView/ItemView control can employ the server-side data as easily as on the client side. But, the DataSource component is designed to rely on the special ASP.NET server-side component-DataService. In other words, it may be a long time before the PHP for Microsoft AJAX Library project to becomes mature.
Next: Post Code Examination >>
More ASP.NET Articles
More By Xianzhong Zhu