简体   繁体   English

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

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

I am running into an error when I attempt to load my website. 尝试加载我的网站时遇到错误。 Whenever I open index.html inside of my browser I get a problem loading page response. 每当我在浏览器中打开index.htmlproblem loading page响应时都会出现problem loading page The response is confusing because normally I would expect this to show that a file could not load, however my response shows the following: 响应令人困惑,因为通常我希望这表明无法加载文件,但是响应显示如下:

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='

It goes on but I've left the rest out for space. 它继续进行,但是我把其余的留给了空间。 As you can see its attempting load my code in the URL, why might this be happening? 如您所见,它试图将我的代码加载到URL中,为什么会发生这种情况?

I've including my javascript code where the browser seems to be attempting to load the file: 我已经在浏览器似乎试图加载文件的地方添加了我的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);

This is my index.html file: 这是我的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>

My directory structure looks like: 我的目录结构如下:

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

  index.html

I'm not sure what I'm doing wrong here, if anyone could offer me some advice I'd really appreciate it. 我不确定在这里我做错了什么,如果有人可以给我一些建议,我将不胜感激。 Thanks! 谢谢!

location is a Javascript keyword . location是一个Javascript 关键字 Rename your variable. 重命名您的变量。

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

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