ajax弹出显示中心在主体
ajax popup display center in body
我想在正文中加载我的弹出中心。我试过了。但它不起作用。这是我的链接:http://sriads.com/shopping/product/(点击Add to Cart
按钮)
this script from :
http://dinbror.dk/bpopup/
头部样式
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://dinbror.dk/bpopup/assets/jquery.bpopup-0.11.0.min.js"></script>
<script src="http://dinbror.dk/bpopup/assets/scripting.min.js"></script>
Jquery
<script>
jQuery(function ($) {
$('.button').on('click', function () {
var id = $(this).data('id');
$.ajax({
url: '/shopping/ajax.php',
data: {
id: id
},
method: 'POST',
success: function (html) {
$('body').append(html);
$(html).bPopup();
},
error: function (returnValue) {}
});
});
});
</script>
按钮html
<button type="button" class="button small cart-button" data-id="2222">Add to Cart</button>
ajax.php文件
<div id="popup">
<div class="inner">
<h2>Item added to your cart!</h2>
<!-- here some html and php codes -->
</div>
</div>
可能height: auto
应该在这里工作。
#popup
:的CSS
#popup {
background-color: #FFF;
box-shadow: 1px 1px 4px #000;
display: none;
height: auto;
width: 450px;
font-family: 'Roboto', Arial;
position: absolute;
margin: 0 auto;
}
要将弹出窗口居中显示到屏幕,您必须设置如下属性-
#popup {
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
position: absolute;
width: 450px; // Any fixed width
height: 300px; // Any fixed height
............
............
}
使用jquery居中弹出;
<script type="text/javascript" >
$('#popup').position({
of: $(window)
});
</script>
相关文章:
- 从桌面读取python文件时高亮显示代码
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何在生成下载文件时显示加载动画
- React重新渲染但未显示正确的组件
- nodejs-expressjs上传图像并显示它们
- 使用JSP从服务器检索和显示图像
- 音频控件在mouseover上显示,在mouseout上淡出
- 让文本输入幻灯片显示输入时的新文本输入?然后向后滑动
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 显示5秒后隐藏潜水
- 画廊图像未显示
- 不显示带有本地json文件数据的谷歌地图脚本
- 如何将json数据显示为html
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- 高亮显示时编辑文本大小和颜色
- 我如何以编程方式显示/隐藏一个按钮,它是流星主体模板的一部分
- 显示:无或可见性:隐藏在页面加载的主体元素-它会影响SEO吗?
- documentElement.innerHTML不显示iframe主体
- ajax弹出显示中心在主体