這次帶給大家ajax如何做出頁面局部跳轉功能,ajax做出頁面局部跳轉功能的注意事項有哪些,以下就是實戰案例,一起來看一下。
透過程式碼範例分析介紹ajax實現頁面局部跳躍與結果返回,具體內容如下:
1、帶有結果返回的提交過程
<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); } }); }
//提报 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(); }
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(); } } } }
以上是ajax如何做出頁面局部跳躍功能的詳細內容。更多資訊請關注PHP中文網其他相關文章!