A bug where Ajax and Bootstrap are mixed with hand remnants

Source: Internet
Author: User

The front end is like this

The original logic is to click Submit, the Modal box appears, and then click on the comment after the data submitted to the backend with Ajax, it looks OK, but the hand is two buttons nested together,

(The code is not complete)

The wrong code

$ ("#回复按钮"). On (' click ', function () {//Get information about the reply object;        $ ("Comment in Modal Box"). On (' click ' function () {//Get the nickname and content in the popup box.) Ajax ({transfer data;    }); )};)};

and then the problem comes., we can see this effect

Comments 1 Normal, comments 2 showing two times, reviews three tests showed three times.

The problem is on the nesting of two button on click events

Press the external button for the first time to start listening for the internal button comment is pressed, the second time the external button is pressed, the first external button listens for the internal button to be clicked, The second external button is also listening, so the server post two times data, and so on ...

Solution to separate the click events for two buttons

Correct code

$ ("#回复按钮"). On (' click ', function () {
Obtain the information of the reply object;
)};

$ ("comments in pop-up Box"). On (' click ' function () {
Get the nickname and content in the popup box
. Ajax ({
Transmitting data;
});

)};



A bug where Ajax and Bootstrap are mixed with hand remnants

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.