我试图在点击事件发生时触发模式。问题是刷新或登录页面时弹出模式对话框或警报框。无法弄清楚我要去哪里错了,谁能解决这个问题。
jquery逻辑:
isAuthenticated
模式标记:
$(".report_offence").on("click", function(){
var reporter=$(this).attr('attr');
var offender=$(this).attr('id');
var post_id=$(this).attr('type');
alert(reporter);
$("#exampleModal").modal('show');
$.post("others/report_offence.php",{"reporter": reporter,"offender":offender,"post_id":post_id},function(data){
console.log(data);
});
return false;
});
这是模式的触发因素:
<div class="modal-quirk">
<div class=" modal-popup">
<div class="modal in fade" id="exampleModal" role="dialog" aria-labelledby="exampleModalLabel" data-dismiss="modal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">New message</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Recipient:</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="message-text" class="col-form-label">Message:</label>
<textarea class="form-control" id="message-text"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Send message</button>
</div>
</div>
</div>
</div>
</div>
</div>