Tips for passing values on HTML5 + js pages to the Java Background: html5js

Source: Internet
Author: User

Tips for passing values on HTML5 + js pages to the Java Background: html5js

Tips for page value passing

For a web project we usually do, there are several steps on an HTML page, step_num ①, step_num ②, step_num ③. step_num ① is displayed first, and step_num ② is displayed according to the jump condition, step_num ① hide, jump to step_num ③, step_num ①, step_num ② hide, step_num ③ show.

Idea: (js sets global variables, where to add an input tag, assigns the value to an input, and then hides the input ).

First, let's talk about the structure of the webpage. Go to the xxx.html page and send an ajax. postForm request through js to request an action. action calls handler. Each function requests an action.

 

Two days ago, we made such a page. When we passed the value, we encountered a problem that made the human brain hurt. We need to display and undisplayed values in step_num ①, passed To step_num ③ the corresponding background Java code. I was also very drunk. I tried several methods and it was not easy to use. Finally, I used a small trick.

Set a global variable in js, such as var groupID = "";, and then assign the GroupID passed from step_num ① from the background action to groupID, how can I transmit the data to the corresponding Java backend of page 3?

Enter the following statement in the HTML code corresponding to step_num ③: <input id = "chuanzhi" name = "chuanzhi" type = "hidden"/>

Then, in the corresponding js Code, set $ ("# chuanzhi"). val (groupID );

In this way, you can get the groupID you want through request. getParameter ("chuanzhi") in the corresponding Java background of step_num ③.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.