【发布时间】:2016-10-26 17:11:07
【问题描述】:
我有一个链接点击它正在发送ajax请求并成功获得响应,这是html文件,我附加到div,但我需要将div显示为modal popup,我试过了下面的东西。
在html 文件中
<a th:if="${ratingSummary}" href="#" class="small dark account review_ratings_login">Login to write a review</a>
<div id="login_for_review" data-toggle="modal" data-target="#reviewLoginModal"></div>
在js 文件中
$(document).on('click', '.review_ratings_login', function () {
var $data = $('#review_product_id span').text();
var url = '/mycompany/login/'+$data;
$.ajax({
type: 'GET',
url: url,
success: function (output) {
$('#login_for_review').html(output).modal('show');// I tried to show this response as modal popup
},
error: function(output){
alert("fail");
}
});
});
output文件
<div class="centerForm modal fade" role="dialog" style="margin-left: 35%;" id="reviewLoginModal">
<div class="modal-dialog modal-sm" >
<div class="modal-content">
// here I have login form
</div>
</div>
但我没有得到这个html output modal pup 而是得到black screen 任何人都可以帮助我如何做到这一点?
【问题讨论】:
标签: javascript java jquery html ajax