happmaoo 发表于 2013-1-23 01:37:04

在EasyJWeb中轻松开发Ajax运用

<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog01.html" frameborder="0" width="728" scrolling="no" height="90"></iframe><div class="postText">  Web2.0正如火如荼,其生动的界面支持迎来了B/S应用的第二春,从EasyJWebhttp://wiki.easyjf.com/images/icons/linkext7.gif-0.8版本开始,你会发现使用EasyJWebhttp://wiki.easyjf.com/images/icons/linkext7.gif开发Ajax的应用会很方便,本文简单介绍EasyJWeb中Ajax的运用示例。
  web脚本远程调用简介
  在基于Web2.0的程序中,在用户注册的时候,我们希望用户在输入完注册用户名后,假如其输入的用户已经存在,则立即显示相应的提示,这样的交互会使得应用程序交互界面变得更加友好。要实现这种功能,可以通过在用户输入完用户名时,触发一个事件,这个事件执行一个程序,自动到服务器端检测这个用户名是否存在,若用户已经存在,则给予相应的提示,让用户可以及时选择其它用户名继续操作。
  假如我们在服务器端有一个用户处理组件UserServicehttp://wiki.easyjf.com/images/icons/plus.gif,这个组件中有一个检测用户是否存在的方法boolean checkUserExists(String userName),这个方法用来检测用户名是否存在,若存在则返回true,否则返回false。
  引入远程脚本调用,则可以直接在注册页面中使用下面的javascript脚本来判断用户是否存在:
<div class="code"><div class="codeContent"><div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.giffunctioncheckUserExist(username)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gifUserService.checkUserExists(username,function(ret)...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifif(ret)Element.update("userName_Msg","用户名已存在,请选择其它用户名!");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif})
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
页: [1]
查看完整版本: 在EasyJWeb中轻松开发Ajax运用