Differences between button and submit in jQuery ajax

Source: Internet
Author: User

Copy codeThe Code is as follows: <script type = "text/javascript">
$ (Document). ready (function (){
$ ("# Submit"). click (function (){
$. Post ("sendPwd. php ", {QQnum: $ (" # QQnum "). val (), psw: $ ("# psw "). val ()}, function (data ){
$ ("# Aaa" ).html (data );
}, "Html ");
});
});
</Script>

There should be no problem in writing the post method of jQuery ajax in this way. Click the submit button, sendPwd. php receives the passed value through $ _ POST, and then echo a piece of data. However, the returned values cannot be displayed. The reason is as follows:Copy codeThe Code is as follows: <input type = "submit" name = "submit" id = "submit" value = "submit"/>

The type of the submit button is submit. After clicking the button, there is no response. Because I accidentally found that the results were returned when I clicked the button, I found it strange. I checked it online and found that most of the buttons were set to the button type, so I changed it to the button type, the problem is solved.

What is the difference between button and submit?
The submit mainly refers to the submission form. It is a special button that executes the submission action. The button mainly works with javascript operations and is itself a button. This is the fundamental difference. If you want to use submit, return false is required for verification. I think it is more convenient to set a button.

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.