如何使用ajax调整Fancybox的大小
当我使用ajax时,我无法调整fancybox的大小...... 这就是我的代码的样子:
$(".button").click(function() {
var formData = $(this).closest('form').serializeArray();
formData.push({ name: this.name, value: this.value });
$.ajax({
type : "POST",
cache : false,
url : "<?php echo plugins_url(); ?>/kryssord-opplaster/opplasting/utfoerOppgave.php",
data : formData,
success : function(data) {
$.fancybox(data);
}
});
return false;
});
如何调整 $.fancybox(data); 的大小? 我尝试了“.....$.fancybox(data, {'width': '50%', 'height': '75%'})...”,
但这根本不起作用..谢谢进步!
更新:
看起来我的 HTML 代码中只有一些错误。 我设置了
而不是
不知何故,我现在编码的方式,如果我在 php 文件(url)中设置样式表,它也会影响后台的页面.. 所以最好的事情是如果我可以在 iframe 中获取 ajax 页面。但是,如果我将 fancybox-script 编辑为 ..$.fancybox(data, {'type': 'iframe'});
我收到 403 错误..
有人可以帮我修改上面的代码吗?
I can't resize my fancybox, when I use ajax...
This is how my code looks like:
$(".button").click(function() {
var formData = $(this).closest('form').serializeArray();
formData.push({ name: this.name, value: this.value });
$.ajax({
type : "POST",
cache : false,
url : "<?php echo plugins_url(); ?>/kryssord-opplaster/opplasting/utfoerOppgave.php",
data : formData,
success : function(data) {
$.fancybox(data);
}
});
return false;
});
how do I resize the $.fancybox(data);?
I tried ".....$.fancybox(data, {'width': '50%', 'height': '75%'})..."
but that didn't work at all.. Thanks in advance!
Update:
Seems like I only had some errors in my HTML-code..
I had set <table><form></form></table>
instead of <form><table></table></form>..
And somehow the way I've coded it now, if I set a stylesheet in the php-file (the url) it affects the page in the background as well.. So the best thing would be if I could get the ajax-page inside a iframe. However if I edit the fancybox-script to ..$.fancybox(data, {'type': 'iframe'});
i get a 403 error..
could someone help me modify the above code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个,将其添加到 html 源
Try this, add this into html source
<div id="successContainer"></div>
您是否正在尝试将其大小调整为一定的高度和宽度,或者只是让它自动调整大小以适应内容?
尝试将其放入ajax成功部分:
或者尝试:
至于更新,我有点不清楚你想要做什么,你能澄清一下吗?为什么需要 iframe?
Are you trying to resize it to a certain height and width, or just have it automatically resize to fit the content?
Try throwing this into the ajax success portion:
Or try:
As for the update, I'm a little unclear of what you're trying to do, could you clarify? Why do you need the iframe?