简体   繁体   中英

Form onsubmit not working when loaded via ajax

When the below content is loaded via Ajax its not working:

<form action="...." onsubmit="return confirm('Do you really want to cancel this plan?');">

The confirm dialog box does not appear. There are multiple form with same action. The binding using Jquery wouldn't work as there isn't a single id. Shall I bind using jquery on event using a class name?

You better use the onclick event of your submit button(s).

For example:

<form method='post'>
    <input type='submit' name='undo' value='Undo' onclick="return confirm('Do you really want to cancel this plan?');"/>
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM