我在apache中使用perl-cgi代码中的javascript文件(json2.js)。但当我在浏览器上运行它时,它无法找到源代码,并返回以下错误:“无法加载资源:服务器响应状态为404 (未找到)”
我的doumentroot路径是: /srv/www/cgi-bin,脚本的路径是: /srv/www/cgi-bin/scripts
我这样做;
 print "<script type='text/javascript' src='./scripts/json2.js'></script>"; # Line 1
    print "<script type='text/javascript' language='JavaScript'>
    function setDetails(o,json_arrRef,arrSize){
            alert('hello='+arrSize+' || ref='+json_arrRef); // till here it works fine
            var json_obj = JSON.parse(json_arrRef);     
    }
    </script>";如果我将第1行编辑为
print "<script type='javascript' src='./scripts/json2.js'></script>";它会找到源代码,但在调用'JSON.parse()‘时会出现以下错误;'Uncaught : Unexpected非法’
我做错了什么吗?
发布于 2010-12-27 21:27:19
https://stackoverflow.com/questions/4538879
复制相似问题