2007-03-01 AJAX 設計要點

經過昨天的一格之後
我今天十一點就開始寫格了

身為一個網頁編程, 網站主管
機緣巧合之下走進了主流的編程語言的世界
難得有甚多的時間做試品
綜合幾個月的功力
總結一下ajax + php 設計系統時的要點

萬一定位為ajax 站
先要決定那一個部分用上ajax
那一個部分用上form submit

將會用到那些ajax librarys
prototype? dojo?

接著是一個意外的問題
那個地方是可以給人bookmark, 用前一頁, 下一頁按鈕
意外地, 坊間的絕大部分ajax教學都不會提到bookmark 對一個商用網站的重要性
可能因為設計時的複雜性吧
我自己一般對ajax 網頁的評分
第一個著眼點便是bookmark 支持了
既容易觀察, 又準

ajax request 也有要點
用上一個統一的ajax request
但用不同的parameters
parameters 用兩個attribute pass-in
一個是指明ajax 性質, 既actions
另一個是其他, pass-in a=b&c=d&.......
除錯, 加減功能的修改都會容易得多
PHP 用上一個switch $_GET[''action'']
跳到不同的function 就可以了

最後
推介幾個javascript library
dhtmlhistory 用作紀錄history, bookmarks
json 用作 ajax response parsing, 方便過xml

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <h4> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options