通过代码示例分析给大家介绍ajax实现页面局部跳转与结果返回,具体内容如下:
<input type="button" class="btn" value="提报" name="submit4" onClick="tibao();">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); } });}后台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(); }这里做的操作的结果是反映到response对应的位置,于是拿到属于response的流,而不是new一个出来。
使用AJAX如何实现页面跳转
function doGuahao(){ if(checkdata()) { if(document.form1.result_flag.value=="0") { return false; } else { if(document.form1.checktype.value=="danganhao") { form1.action = "<%=formAction%>"; form1.submit(); } if(document.form1.checktype.value=="xingming") { form1.action = parent.left.url2; form1.submit(); } if(document.form1.checktype.value=="shenfenzheng") { form1.action = "<%=formAction%>"; form1.submit(); } } } }
零七网部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与零七网进行文章共享合作。