Advantages and disadvantages of submitting Ajax and hidden form

Source: Internet
Author: User
Tags blank page

  This article is mainly to the AJAX submission and form submission of the difference between the detailed introduction, the need for friends can come to the reference, I hope to help you.

Now compare the pros and cons of Ajax with hidden form submissions.   1. Hide form submission, update data after the completion of the need to go to a blank page and then the original page to submit 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 cannot upload files through Ajax, and by hiding form submissions You can do this, so this is the main purpose currently submitted with a hidden form.   Now next describes how to implement file uploads by hiding the form   1) First define a form for filling out 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   < The iframe name= "Myiframe" style= "Display:none" ></iframe>  //is used to store the blank page   <div id= "Forminner" after the return of the submission Style= "Display:none" ></div>  //used to get Form1 HTML content, get Form1 table cell element   </form>   3) at Form1 submission, Do the following JavaScript processing   var forminner= document.getelementbyid ("Forminner"); forminner.innerhtml = form1.innerhtml;  //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.   such as the original page defines a updatepagefromsubmit (), then theblank.jsp pages can be parent.updatepagefromsubmit () to invoke processing after a commit return  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.