浏览器尝试以文件结构打开 Javascript 代码



我在尝试加载我的网站时遇到错误。每当我在浏览器中打开index.html时,我都会得到problem loading page响应。响应令人困惑,因为通常我希望这会显示文件无法加载,但是我的响应显示以下内容:

Firefox can’t find the file at /home/crow/UdacityProjects/mapapp/function (data) { // Setting Self var self = this; this.name = data.name; this.lat = data.lat; this.long = data.long; this.URL = ""; this.street = ""; this.city = ""; this.phone = ""; this.visible = ko.observable(true); // Foursquare URL var foursquareURL = 'https://api.foursquare.com/v2/venues/search?ll=' this.lat ',' this.long '&client_id=' clientID '&client_secret='

它继续,但我把其余的留给了空间。正如你所看到的,它试图在URL中加载我的代码,为什么会发生这种情况?

我已经包含了我的javascript代码,浏览器似乎正在尝试加载文件:

// --- Location information and foursquare URLJSON.
var location = function(data) {
  // Setting Self
  var self = this;
  this.name = data.name;
  this.lat = data.lat;
  this.long = data.long;
  this.URL = "";
  this.street = "";
  this.city = "";
  this.phone = "";
  this.visible = ko.observable(true);

这是我index.html文件:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Bolton Hill Neighborhood Map</title>
  <link rel="stylesheet" href="static/main.css">
  <meta name="viewport" content"width=device-width, initial-scale=1">
</head>
<body>
 <div class='map'>maps error</div>
  <script src="/js/knockout.js"></script>
  <script src="/js/jquery.min.js"></script>
  <script src="/js/app.js"></script>
  <script async defer src="https://maps.googleapis.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&callback=initApp&libraries=places" onerror="errorHandler"></script>
</body>
</html>

我的目录结构如下所示:

myapp
|
  CSS
   |
    main.css
  JS
   |
    knockout.js
    core.js
    jquery.min.js
    app.js
  index.html

不确定我在这里做错了什么,如果有人能给我一些建议,我将不胜感激。谢谢!

location是一个Javascript关键字。重命名变量。

最新更新