我有一些JavaScript代码可以在FireFox中运行,但不适用于Chrome或IE.
在Chrome JS控制台中,我收到以下错误:
"Uncaught SyntaxError:意外的输入结束".
我使用的JavaScript代码是:
<script>
$(function() {
$("#mewlyDiagnosed").hover(function() {
$("#mewlyDiagnosed").animate({'height': '237px', 'top': "-75px"});
}, function() {
$("#mewlyDiagnosed").animate({'height': '162px', 'top': "0px"});
});
</script>
Run Code Online (Sandbox Code Playgroud)
它说错误是在最后一行 });
运行此JSON.parse时,我在浏览器控制台中不断收到"Uncaught SyntaxError:意外的输入结束".我尝试将$元素缩短为$ entry但仍然没有成功:
function getFileList() {
var elements;
var foo = document.getElementById("filelist");
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", complete, true);
// foo.innerHTML= xhr.responseText;
xhr.onreadystatechange = function () {
console.log(JSON.parse(xhr.responseText));
}
xhr.open("GET", "php/dir_list.php", true);
xhr.send(null);
function complete() {
eventAssign();
xhr.removeEventListener("load", complete, false);
}
}
<?php
$files = array();
if ($handle = opendir('/trunk')) {
$i = 0;
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$element = '<li><a class="files" id="listFile'.$i.'" data-filename="'.$entry.'" href=php/download.php?filename='.$entry.'>'.$entry.'</a></li>';
$checksum = …Run Code Online (Sandbox Code Playgroud)