2015-06-19 15 views
1

我是javascrpting的新手,這是一個完全新手的問題。錯誤在.html指出,並指向.js

我有一個index.html文件看起來像:

<!DOCTYPE html> 
<html> 
<head> 
<title>The d3 test</title> 
<style> 
.chart { 

} 

.main text { 
    font: 10px sans-serif; 
} 

.axis line, .axis path { 
    shape-rendering: crispEdges; 
    stroke: black; 
    fill: none; 
} 

circle { 
    fill: steelblue; 
} 

</style> 
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script> 
</head> 
<body> 
    <div class='content'> 
     <!-- /the chart goes here --> 
    </div> 
    <script type="text/javascript" src="scatter.js"></script> 
</body> 
</html> 

注意scatter.js這裏是一個JavaScript來創建一個d3.js情節。

此代碼將無法正常工作,當我嘗試來檢查使用Chrome和Ctrl+Shift+J錯誤,我得到這個錯誤: enter image description here

這是什麼錯誤,爲什麼瀏覽器混淆.html.js

+0

您使用的是什麼http服務器? – Craneum

+0

我正在使用[django](https://www.djangoproject.com/) – farhawa

+0

使用curl和-i標記獲取scatter.js併發布結果。此外,請張貼URL路徑(即/static/scatter.js,/widgets/index.htm等) – Craneum

回答

0

位於與index.html相同的文件夾中的scatter.js?
如果不是,您必須指定完整路徑而不是src =「scatter.js」

+0

'scatter.js'和'index.html'是在同一個目錄。但是,無論如何感謝你的回答 – farhawa

+0

這意味着如果你把完整的路徑,你有相同的錯誤?像「/scatter.js」甚至「http:..../scatter.js」?如果是,你有具體的.htaccess? –