【发布时间】:2016-09-20 06:17:35
【问题描述】:
火灾后如何显示Bootstrap Modal jQuery function ?
这是我的功能
$(".add-to-fav").click(function () {
event.stopPropagation();
event.preventDefault();
var id = $(this).attr('id');
var is_favorite;
if ($(this).hasClass('glyphicon-star-empty')) {
$(this).removeClass('glyphicon-star-empty').addClass('glyphicon-star');
is_favorite = 1;
} else {
$(this).removeClass('glyphicon-star').addClass('glyphicon-star-empty');
is_favorite = 0;
}
jQuery.ajax({
type: "POST",
url: "<?php echo base_url(); ?>" + "files" + "/" + "add_favorite",
dataType: 'json',
data: {selected_id: id, is_favorite: is_favorite},
success: function (res) {
if (res)
{
$("div#result").show();
$("div#value").html(res.id);
$("div#value").html(res.is_favorite);
}
}
});
location.reload(true);
});
功能正常运行。
我想在触发location.reload(true); 之前显示带有重新加载gif 的模态@
谢谢。
【问题讨论】:
-
不要做 ajax 并重新加载
-
为什么?但我想发送ajax请求。功能正常。
-
为什么要创建 ajax?
-
如果我在视图中点击了收藏按钮,则使用 ajax 将点击的表格行 id 发送到控制器
-
你为什么不做一个简单的get/post请求?
标签: jquery twitter-bootstrap bootstrap-modal reload