Traps caused by different types of input and button values when submitting forms through Ajax

Source: Internet
Author: User

Today, when using connection for form submission, we found that setting the type attribute in the tags "input" and "botton" is also a learning issue.
In the development process CodeMore clean, I first use Yahoo. util. event. addlistener (OBJ, "click", callback) class loads the "click" event to submit the form, Yahoo. util. connect. the asyncrequest ('post') method is used to upload form data. If the form information is incorrect, it is returned for processing. The button for submission uses <button type = "Submit"> submit </button>.
Besides IE6 being able to correctly process my form data, Firefox and IE7 cannot respond to my error handling (in the callback method, if an error is encountered, return false ).
In this case, I thought that I had already done the return processing before submitting the form data in the statement. How can I refresh the page.
When I returned home in the evening, I tested the problem I encountered today. I found that I ignored a little bit and the data was indeed submitted. In addition, I can clearly see all kinds of data in the address bar, as it turns out, the data must have been submitted, so I thought of my button. the category of the button is set to "Submit". When I was writing code, both are directly in "input" or "button". If the category is set to "Submit", onclick = "Return fun () is written in this way (); "Or onclick =" Fun (); Return false; "; this is naturally not a problem. It is strange that the value of the addlistener class does not directly affect the button, when you click the button, data is submitted.
Miserable ~~~~
Appendix: The default type value of the button is submit, so it is best to identify the category !!! Remember!
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.