张昊

J-Hi(http://www.j-hi.net)

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  45 Posts :: 1 Stories :: 110 Comments :: 0 Trackbacks

1.前台页面:

//自定义一个回调函数ajaxDone

<form action="expert_BaseInformationSave.action?navTabId=expert_BaseInformationList&callbackType=closeCurrent&ajax=1"

method="post" class="pageForm required-validate" onsubmit="return validateCallback(this, ajaxDone)">

 

//回调函数

<script type="text/javascript">

       function ajaxDone(json)

       {

              alert(json.expert.name);

       }

</script>

 

2.后台代码:

public class Expert_BaseInformationSaveAction extends BaseAction implements SynchronizationData{

       private Expert_BaseInformation expert_BaseInformation;

       private JSONObject json;

 

       public String execute() throws Exception {

              Expert_BaseInformationManager expert_BaseInformationMgr = (Expert_BaseInformationManager)

SpringContextHolder.getBean(Expert_BaseInformation.class);

              if(super.perExecute(expert_BaseInformation)!= null) return returnCommand();

              expert_BaseInformationMgr.saveExpert_BaseInformation(expert_BaseInformation);

              super.postExecute(expert_BaseInformation);

              json = new JSONObject("expert", expert_BaseInformation, "name, gender, unit");

             

              return "json";

       }

      

       public Expert_BaseInformation getExpert_BaseInformation() {

              return expert_BaseInformation;

       }

 

       public void setExpert_BaseInformation(Expert_BaseInformation expert_BaseInformation) {

              this.expert_BaseInformation = expert_BaseInformation;

       }

 

       public JSONObject getJson() {

              return json;

       }     

}

 

注意:action中必须定义public JSONObject getJson() {

              return json;

       } 否则前台无法获取json数据。



                                     注:该文档由J-Hi爱好者"笨笨"提供,他的QQ号为289542213,欢迎大家与他在技术上多多交流


posted on 2011-05-29 22:21 张昊 阅读(861) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: