我正在尝试在页面上单击链接后发送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>
答案 0 :(得分:0)
我明白了。在加载jQuery之前,我已经加载了jQuery代码。我讨厌这样做1