Now compare the pros and cons of Ajax with hidden form submissions.
1. Hide form submission, update the data after the completion of the need to go to a blank page and then the original page submitted after processing; Ajax is not, you can directly return to the original page for processing after submission. Visible Ajax can add a page less than the hidden form submission.
2.ajax for security reasons, you cannot operate on files, so you can't upload files through Ajax, and you can do this by hiding form submissions, so this is the main purpose that is currently submitted with a hidden form.
Now let's talk about how to upload files by hiding the form
1 First define a form to fill in the forms
<form name= "Form1" ></form>
2) then define a form for submission
<form name= "Form2" target= "myiframe" >//To specify that the returned page of the submission is displayed in this hidden iframe
<iframe name= "Myiframe" style= "Display:none" ></iframe>//For storing a blank page after submitting the return
<div id= "Forminner" style= "Display:none" ></div>//For obtaining Form1 HTML content, obtaining Form1 form elements
</form>
3 when Form1 commits, the following JavaScript processing is done
var forminner= document.getelementbyid ("Forminner");
forminner.innerhtml = form1.innerhtml; To copy Form1 HTML code
Form2.action = form1.action;
Form2.submit ();
4 after the submission, into the background processing, after the completion of the background processing, you need to return a blank page blank.jsp, this page is generated in the hidden iframe, so you can use the parent object to the original page to operate.
For example, the original page defines a updatepagefromsubmit (), then the blank.jsp page can be called through the Parent.updatepagefromsubmit () to the processing of the return after the submission