各セクションから異なる画像をロードし、すべてのセクションに画像スライダーを使用する必要があります。
例: セクション タブ: IT - 情報セキュリティ - 水開発 ...など。
次に、ユーザーが任意のセクションをクリックすると、このセクションに関連する画像スライダーが表示されます。
だから私は Ajax でそれを作成しました。
ホームページ :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test </title>
<link rel="stylesheet" type="text/css" href="demo.css" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="newscript.js"></script>
<link href="themes/2/js-image-slider.css" rel="stylesheet" type="text/css" />
<script src="themes/2/js-image-slider.js" type="text/javascript"></script>
<link href="generic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="rounded">
<img src="img/top_bg.gif" alt="top" /><div id="main" class="container">
<ul id="navigation">
<?php
include("samiloxide.php");
$sql=mysql_query(" select * from section ");
while($r=mysql_fetch_array($sql)){
echo "<li><a onclick='loadpage($r[id])' >$r[section]</a></li>" ;
}
?>
<li><img id="loading" src="img/ajax_load.gif" alt="loading" /></li>
</ul>
<div class="clear"></div>
<div id="pageContent">
</div>
...........
JavaScript ファイル:
var section;
function loadpage(section){
var section = section.toString();
$.ajax({
type: "POST",
url: "get.php",
dataType: "script",
data: ({section : section}),
success: function(html){
$("#pageContent").empty();
$("#pageContent").append(html);
}
});
}
-------
get.php ファイル:
<div id="sliderFrame">
<div id="slider">
<?php
include("samiloxide.php");
//if(!$_POST['page']) die("0");
$section = (int)$_POST['section'];
$sql=mysql_query(" select * from images where section='$section'");
while($rr=mysql_fetch_array($sql)){
echo " <img src='$rr[image]' alt='text..' />";
}
?>
</div>
.....
スライダーは機能せず、スライド効果なしで画像をロードするだけです!! しかし、ブラウザからget.phpを呼び出すと...など、うまくいきます??!! 私の Ajax コードの問題は何ですか?