Home > Web Front-end > JS Tutorial > body text

How to make a partial page jump function in ajax

php中世界最好的语言
Release: 2018-04-25 16:14:34
Original
2390 people have browsed it

This time I will show you how ajax can make a partial page jump function. What are the precautions for ajax to make a partial page jump function? The following is a practical case, let's take a look.

Through code sample analysis, I will introduce to you the implementation of ajax to achieve partial page jump and result return. The specific content is as follows:

1. Submission process with result return

A submit button is used to demonstrate here. The HTML code is:

<input type="button" class="btn" value="提报" name="submit4" onClick="tibao();">
Copy after login
After clicking the report button, ajax is used to jump to the action for processing.

JavaScriptThe code is:

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);
        }
  });
}
Copy after login
After the action processing is completed, the returned result will be placed in the result, and a prompt message will pop up on the page; of course, the action jump here needs to be configured with xml.

The background Java class processing process is:

//提报
    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();
    }
Copy after login
Here, the data is processed through a sql statement, a message is returned, and the information is printed to the page;

The result of the operation done here is reflected to the position corresponding to the response, so the stream belonging to the response is obtained instead of a new one.

That is to say, if I jump from there, my information will be returned there. So in js, you can use result to receive the returned result, and use alert to prompt.

How to use AJAX to achieve page jump

The sample code is as follows:

The ajaxAnywhere framework is used in the project to implement ajax , the effect is good and easy to implement, but the problem now is that even if the page achieves the effect, the business still needs to submit the form. In this case, even after clicking submit, it will still refresh the zone area you defined. At this time, If simply submitting the form is not enough, the solution I adopted is:

Use js, a powerful BS project development tool, to self-define a function

to solve the above problem:

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Ajax implements Loading effect


JS implements ajax call background definition (with code)

The above is the detailed content of How to make a partial page jump function in ajax. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!