繁体   English   中英

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

[英]Browser attempting to open Javascript code as file structure

尝试加载我的网站时遇到错误。 每当我在浏览器中打开index.htmlproblem loading page响应时都会出现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 关键字 重命名您的变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM