-2
我想發送參數化函數中的數組值,但我不知道爲什麼我無法做到這一點。示例代碼是:功能不能發送數組值
<ul>
<?php
while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$photoname = $row['photoname'];
$string = array();
$recreated = 'cmVjcmVhdGVk/';
$thumb = 'dGh1bWI=/';
$original = 'b3JpZ2luYWw=/';
$filePath = "albums/$album/$album$thumb";
$dir = opendir($filePath);
while ($file = readdir($dir)) {
$info = pathinfo($file);
if (($info["extension"] == "jpg") || ($info["extension"] == "gif") || ($info["extension"] == "png")) {
$string[] = $file;
}
}
}
while (sizeof($string) != 0) {
$img = array_pop($string);
$fileBigPath = "albums/$album/$album$recreated";
echo "<li class='ui-state-default'><a href='#' onclick='details(" . $img . "); return false'><img src='$filePath$img'></li>";
}
?>
</ul>
</div></div>
<script>
function details(id) {
alert(id);
params = "id=" + encodeURIComponent(id);
alert(params);
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
lBackground = document.createElement('div')
lBackground.className = "lBackground";
lBackground.setAttribute("id", "lBackground");
lBox = document.createElement('div');
lBox.className = "lBox";
lBox.setAttribute("id", "lBox");
lContents = "";
lContents = xmlhttp.responseText;
lBox.innerHTML = lContents;
document.body.appendChild(lBox);
document.body.appendChild(lBackground);
}
}
xmlhttp.open("POST", "abc.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(params);
}
</script>
這是示例代碼。
我想是的,我想文件名要
您的代碼不完整..請重新發布! – 2013-03-09 08:22:55
你關心縮進嗎? – 2013-03-09 08:24:22
你的問題不清楚,代碼不清楚。 – bgusach 2013-03-09 08:26:55