简体   繁体   中英

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. 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?

I've including my javascript code where the browser seems to be attempting to load the file:

// --- 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:

<!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 . Rename your variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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