2006-11-14 15:01:00 归档在 我的博文 | 浏览 940 次 | 评论 0 条
Today I’ve created simple AJAX-enabled plugins for Smarty. I don’t try to develop powerful reach-applications framework. I can give you only idea how to integrate AJAX-technology into Smarty. But if you have any offers how to improve anything I’ve described or if you just want to leave feedback please post you comments on my site. In my practice I need several things from AJAX: to update some nodes in DOM, to send forms without post-back, to retrieve some values or to perform server-side calculation (maybe using database or other server-side resources). It’s necessary to write tons of JavaScript to implement my requirements in spite of using cool JavaScript library Prototype. I’ve decided to integrate Smarty with AJAX. There are three Smarty plugins has been created: ajax_update, ajax_call, ajax_form. Below all this plugins will be described. ajax_updateThis Smarty function can be used for update some parts of web-page. Sample usage: <a href="#" onclick="{ajax_update update_id='intro_content' function='update_intro' params='page=about'}">About</a> Possible parameters:
ajax_callThis Smarty function can be used for call PHP function on server side and retrieve its output. Sample usage: <a href="#" onclick="{ajax_call function='calculate' params_func='calc_params' callback='calc_cb'}">Calculate</a> Possible parameters:
ajax_formThis Smarty block can be used for submit Web-forms without post-back. Sample usage: {ajax_form method="post" id="form_register"}
Any form-element can be placed here
{/ajax_form} Possible parameters:
SamplesThese plugins are quite simple and I think everyone can create even better than mine. I’ve just wanted to show you idea how integration can be done. Working examples can be found here. Also you can download full sources. 上一篇 << 莲山公园 1 下一篇 >> 收集的SEO相关工具整理发布出来&…
|
|