AJAX is AsynchronousJavascriptAndXML (Asynchronous JavaScript and XML). It is a Web page development technology used to create interactive web applications. It exchanges a small amount of data with the server in the background, AJAX can enable asynchronous updates on webpages. This article describes how to implement partial page Jump and result return in ajax, if you are interested, let's take a look at the sample code to introduce you to ajax for partial page Jump and result return. The specific content is as follows:
1. submission process with returned results
Here we use a submit button to demonstrate the HTML code:
Click the submit button and use ajax to jump to the action for processing. The JavaScript code is:
function tibao(){var id='';var URL =
+id; $.ajax({url: URL, type: 'GET', success: function(result) { alert(result); } });}
After the action is processed, the returned result is put into the result, and a prompt message is displayed on the page. Of course, xml must be configured for the action jump here.
The background Java class processing process is as follows:
// Report 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.exe cute (); PrintWriter write = response. getWriter (); write. print (helper. getOutput ("message"); write. close ();}
Here we use an SQL statement to process the data, return a message, and print the information to the page;
The result of the operation here is to reflect the corresponding location of the response, so we get the stream that belongs to the response, instead of the new one.
That is to say, if I jump from there, I will return this information. Therefore, you can use the result in js to receive the returned result and use the alert prompt.
How to achieve page Jump using AJAX
The sample code is as follows:
The project uses the ajaxAnywhere framework to implement ajax, which has good results and is easy to implement. But now the problem is that even if the page achieves results, the business still needs to submit forms. In this case, even after you click Submit, it will refresh the region you have defined. At this time, if you simply submit the form, the solution is:
Use js, a powerful BS project development tool, to customize a function to solve the above problems:
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(); } } } }
The above content is described in this article how to implement partial page Jump and all the content returned by the results. I hope you will like it.