【发布时间】:2013-12-08 18:33:20
【问题描述】:
我有一个使用 ajax 填充文件名的选择元素。
HTML 是:
<select id='load_dropdown' name=loads help_token="load_dropdown" title="">
<option value='' selected='selected'>LOAD</option>
</select>
填充元素的调用是:
$('select#load_dropdown') .load('getFiles.php', {list : 'LOAD'}); //fill the load drop down list
getFiles.php: 是
$dir = $_SESSION['user']['id'] . "/xmls/"; // files are in xmls dir
if ($dirHandle = opendir($dir) ){
}
else {
echo ("<br />getFiles.php: $dir not found.");
exit;
}
echo ("<option selected='selected' value=''><b> $list </b> </option>"); // first line of this drop down option
while (false !== ($fileName = readdir($dirHandle))) {
if ($fileName == "." || $fileName == "..") {
continue;
}
$fileNames[] = $fileName; // collect file names
}
sort($fileNames);
foreach ($fileNames as $fileName) {
$displayName = basename($fileName, '.xml'); // cut .xml at end
echo ("<option value='$displayName'>" . $displayName . "</option>");
}
}
这适用于 Firefox、Chrome、Safari 和 IE10。它不适用于 IE9。
在 IE9 中,选择元素不会填充加载的信息,但我可以看到 getFiles.php 调用返回了正确的数据。调用后选择元素是
有谁知道 IE9 是怎么回事?
谢谢。
【问题讨论】:
-
你使用哪个 jQuery 版本?
-
你能展示你用来填充选择列表的代码吗?
标签: html ajax internet-explorer-9