在我的页面上单击链接后,我试图发送 Ajax 请求。我的设置是这样的:有人单击显示模式弹出窗口的链接。然后它要求他们通过单击“是”来“确认”他们的操作。如果他们单击“是”,我将发送 Ajax 请求以执行所选操作。但是,由于某种原因,我的代码没有触发 Ajax 代码。我的代码如下:
<script type="text/javascript">
$(document).ready(function() {
$('#ajax-remove-completion-date').click(function() {
$.ajax({
type:'POST',
url:'post-update.php',
cache:false,
success: function(response) {
$('#success-remove-completion-date').removeClass('hidden');
}
});
});
});
</script>
HTML:
<a href="#myModal1" role="button" data-toggle="modal"><i class="icon-trash"></i> Remove Completion Date</a>
<div id="myModal1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3 id="myModalLabel3">Remove Completion Date</h3>
</div>
<div class="modal-body">
<p>Are you sure you want to remove the students Completion Date?</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn blue" data-dismiss="modal" id="ajax-remove-completion-date">Yes</button>
<input type="hidden" name="submitted" value="remove-completion-date" />
</div>
</div>