Calculating Machine Calculating Machine - 3 months ago 33
Ajax Question

click button not working in modal

I am generating modal box dynamically. In that modal i have two button. Yes & No.
No will close the modal and that is working properly.
I am facing problem while clicking on Yes button.

Once user click on Yes it will update the database.
Here is the code.

<script type="text/javascript">
$("#btnYes1").on("submit", function(e) {
// $('#btnYes1').click(function (e) {
//$('#btnYes1').click(function() {

Code used to generate Modal box. You can see i tried 2-3 things but it is not working.

var modalval='<a href="#" id="btnYes1" name="btnYes1" data-dismiss="modal" aria-hidden="true" class="btn btn-success">Yes</a>';
modalval += '<a href="#" data-dismiss="modal" aria-hidden="true" class="btn btn-danger">No</a>'; $('#modaltext').append(modalval);


Attach the event listener to your document instead.

$(document).on("click", "#btnYes1", function(e) {
    // Your code..