張昊

          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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 长乐市| 伊宁市| 鄂温| 嵊泗县| 彰武县| 马关县| 杭锦后旗| 淮阳县| 锡林郭勒盟| 丹寨县| 乌海市| 蓬莱市| 安乡县| 阳信县| 石城县| 永康市| 新巴尔虎左旗| 沛县| 饶河县| 阿克苏市| 星座| 东乡| 洞口县| 长岭县| 凤冈县| 横山县| 醴陵市| 博客| 彭泽县| 手游| 高安市| 富源县| 平泉县| 遵义县| 军事| 木里| 介休市| 阿拉善右旗| 桐梓县| 金堂县| 梁河县|