zoukankan      html  css  js  c++  java
  • Ajax实现页面跳转与结果返回

    ajax实现页面局部跳转与结果返回

    1、带有结果返回的提交过程

    这里用一个提交按钮来演示,HTML代码为:

    <input type="button" class="btn" value="提报" name="submit4" onClick="tibao();">

    点击提报按钮后,通过ajax来实现跳转到action中处理,JavaScript代码为:

    function tibao(){
    var id='';
    var
    URL = <select:link page="/smokeplan.do?method=Tibao&idset="/>+id; $.ajax({url: URL,   type: 'GET',   success: function(result) { alert(result); } });
    }

    action处理完成后,将返回的结果放到result中,在页面弹出提示信息;当然这里的action跳转是需要配置xml的。

    后台Java类处理过程为:

    //提报
            public void Tibao(ActionMapping mapping, ActionForm form,
                    HttpServletRequest request, HttpServletResponse response) throws Exception {
                String idset=request.getParameter("idset");
                CallHelper helper = initializeCallHelper("L_SmokeBoxtibaoWLDan", form,request, false);
                helper.setParam("bill_ids",idset);
                helper.setParam("personid",getPersonId(request));
                helper.execute();
                PrintWriter write = response.getWriter();
                write.print(helper.getOutput("message"));
                write.close();
            }

    这里是通过一个sql语句对数据进行处理,返回一个message,并将信息打印到页面;

    这里做的操作的结果是反映到response对应的位置,于是拿到属于response的流,而不是new一个出来。

    也就是说我从那里跳转过来的,我这个信息就会返回到那里去。所以在js中就可以用result进行接收这个返回结果,并且用alert提示。

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    canvas 平移&缩放
    html + css + jquery实现简单的进度条实例
    jQuery Layer mobile 弹出层
    jQuery-全屏滚动插件【fullPage.js】API 使用方法总结
    Hive:select count(distinct)优化以及hive.groupby.skewindata
    Spark Application、Driver、Job、stage、task
    Spark 参数说明
    Xgboost小结与调参
    梯度下降算法过程详细解读
    机器学习杂记
  • 原文地址:https://www.cnblogs.com/sdgf/p/4753929.html
Copyright © 2011-2022 走看看