張昊

          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 張昊 閱讀(888) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 自贡市| 阿坝县| 泸州市| 赫章县| 光泽县| 禄劝| 绥阳县| 清水河县| 沙雅县| 永仁县| 三河市| 太康县| 松桃| 永年县| 闵行区| 乌海市| 宁安市| 阳新县| 固镇县| 襄城县| 沙洋县| 济宁市| 新建县| 鄂托克前旗| 玛纳斯县| 楚雄市| 勐海县| 商河县| 大港区| 宁德市| 肃南| 亳州市| 宜宾市| 武强县| 浦城县| 雅安市| 白玉县| 康马县| 敦煌市| 北辰区| 汾西县|