[英]Gallery fade out & in via jQuery
I've got two little problems with my gallery (here: http://jan.kusenberg.eu/test/fotografie.php ). 我的画廊有两个小问题(在这里: http : //jan.kusenberg.eu/test/fotografie.php )。 I coded it with a friend and some help from the internet, but now I am not able to solve the last problems:
我用一个朋友和互联网上的一些帮助对其进行了编码,但是现在我无法解决最后的问题:
This is the code behind the main gallery page (which then includes sub-pages that only draw the pictures from folders, "fotografie_1.inc.php", for example): 这是主图库页面(然后包括仅从文件夹“ fotografie_1.inc.php”中绘制图片的子页面)后面的代码:
<div id="frame_content">
<?php
if ( empty ($_GET['content']) or !$_GET['content']) { $file = 'fotografie_1.inc.php'; } else {
$file = $_GET['content'].".inc.php";}
if(file_exists($file)) {
include($file);
}
?>
</div>
<script>
function getthings(param1, param2)
{
$.ajax({
url: "fotografie_1.inc.php",
type: "GET",
data: { chapter : param1, content : param2 },
async: true
}).done(function(data) {
$("#frame_content").fadeOut("slow");
$("#frame_content").empty();
$("#frame_content").append(data);
$("#frame_content").fadeIn("slow");
});
}
</script>
What am I doing wrong? 我究竟做错了什么?
JS should be like following: JS应该如下所示:
function getthings(param1, param2)
{
$.ajax({
url: "fotografie_1.inc.php",
type: "GET",
data: { chapter : param1, content : param2 },
async: true
}).done(function(data) {
$("#frame_content").fadeOut("slow",function(){
$("#frame_content").empty();
$("#frame_content").hide();
$("#frame_content").append(data);
$("#frame_content").fadeIn("slow");
});
});
}
http://api.jquery.com/fadeout/ You're fading in and out simultaneously which may look odd. http://api.jquery.com/fadeout/您正在同时淡入和淡出,可能看起来很奇怪。 Try:
尝试:
<div id="frame_content">
<?php
if (empty($_GET['content']) or ! $_GET['content']) {
$file = 'fotografie_1.inc.php';
} else {
$file = $_GET['content'] . ".inc.php";
}
if (file_exists($file)) {
include($file);
}
?>
</div>
<script>
function getthings(param1, param2) {
$.ajax({
url: "fotografie_1.inc.php",
type: "GET",
data: {chapter: param1, content: param2},
async: true
}).done(function (data) {
$("#frame_content").fadeOut("slow", function () { //Callback for when the fadeout is done
$("#frame_content").empty();
$("#frame_content").append(data);
$("#frame_content").fadeIn("slow");
});
});
}
$(document).ready(function () {
getthings(1, 'fotographie_1'); // or whatever default is sensible
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.