Yesterday, I used the POST method of jquery ajax to upload values on the page. After a while, no new data is displayed. After a long time, no results are returned. After a long time, no syntax errors are returned, finally, I realized what the problem was.
<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:
<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.
(I am talking about the original blog, Author: Tan Teng. Reprinted please indicate the source! Http://tanteng.sinaapp.com/2012/10/button-submit)