5 votes
Accepted

Why are functions defined where a parameter should go?

Two different things here: there is a function and there is a function call In JavaScript, functions are so-called first-class objects, and what this means is that they, like other values, can be ...
kzidane's user avatar
  • 17.6k
4 votes

pset8 infoWindow appearing with wrong marker

Had the same trouble. Fix it with 'var' before 'marker = new...'. Else you overwrite the same variable each time.
Yury's user avatar
  • 41
2 votes
Accepted

CS50 Pset8: Final Questions before Wrap-Up

How does the computer recognize that those few lines inside a JavaScript file is actually html and not JavaScript codes? It doesn't. It's not javascript or html to the function, it's data. When it is (...
DinoCoderSaurus's user avatar
2 votes
Accepted

CS50 Pset8: Info Window Not Showing

One problem is this syntax markers += marker;. That does not add an element to an array in js. The array method push adds elements to an array. Another problem is here marker.addListener(map, "click"...
DinoCoderSaurus's user avatar
2 votes

CS50 Mashup: addMarker clarification

You are always setting myLatLang here var myLatlng = new google.maps.LatLng(42.3770, -71.1256); // Cambridge, Massachussets, so all the markers will go "there". The argument place is the result of the ...
DinoCoderSaurus's user avatar
2 votes

CS50 Finance: Register unique username (/check) problem: pythion GET function not working

JavaScript $.get is asynchronous. It triggers an HTTP request and returns. The code meant to prevent submission runs after submission is processed, and therefore can't prevent it. The preventDefault ...
Blauelf's user avatar
  • 20.9k
2 votes

What purpose does "eventData" serve in the pset8 source code "$("#q").focus(function(eventData)"?

.focus(handler) is short for .on("focus", handler), and installs an event listener, in your case, handler is an anonymous function declared with one parameter. Those handlers, when called, receive an ...
Blauelf's user avatar
  • 20.9k
2 votes
Accepted

How do I cluster markers on a googlemap?

Thanks to @DinoCoderSaurus for your help - basically the problem was that I was trying to instantiate a MarkerClusterer for each individual marker that was added to the array. The solution was to ...
Matt Friend's user avatar
1 vote
Accepted

Final Project Search Suggestions

The main issue I can see if you are making an Ajax request via JQuery's getJSON() method. This method makes a GET Request. Handling this in the POST section of your index function will cause the ...
johnnyd3's user avatar
1 vote

Problem in using API link in fetch command for AJAX

You want to check out the documentation for that api. It can be found here. According to the documentation, after you get your API Key, you add it to the url as a parameter as such: https://api....
bon_homie's user avatar
1 vote

Flask Filter Search/List in Python

I would like to put the data from the data list in a separate file and then get it back to python and then send it to the Html table with the existing jinja syntax and not change anything in the ...
DinoCoderSaurus's user avatar
1 vote
Accepted

How to fix if statements within event listeners in Javascript

In CSS/ or inside head tag <style> #rick { visibility: hidden; } </style> Inside body tag: <script> function rickroll(event){ ...
C--'s user avatar
  • 306
1 vote
Accepted

CS50 Pset8 Finance /check - TypeError: The view function did not return a valid response

if request.method==["GET"]: That should be if request.method=="GET": alternatively, remove it entirely, since you've already said that the function is only valid for a GET: @app.route("/check", ...
curiouskiwi's user avatar
  • 18.6k
1 vote

How to integrate handlebars(written in raw javascript) into django templates

You should stop the django template engine from rendering the contents of your handlebars script block tag. You can do so by wrapping your handlebars' script with {% verbatim %}{% endverbatim %}. So ...
pebox11's user avatar
  • 111
1 vote

Mashup: javascript variable doesn't retain value

Some background, skip if you want: JavaScript can only ever handle one piece of running code at a time. If you did the AJAX request in a synchronous way, waiting for it to complete before you continue,...
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

Access just the text from a db.execute return

Much like you would have seen in the CS50 Finance, db.execute returns a list of dict objects. So just as you accessed the cash value for your index page using rows[0]['cash'] you need to access your ...
curiouskiwi's user avatar
  • 18.6k
1 vote
Accepted

PSET8 invalid sw.

A list of a list. Program expects a list of places. execute returns a list of rows. This return jsonify([placesMatches]) (specifically the []) nests placesMatches into another list.
DinoCoderSaurus's user avatar
1 vote
Accepted

Google Maps Places API Code Not Running - Final Project

I added this line service = new google.maps.places.PlacesService(map); to my pset8 and it gave this message TypeError: google.maps.places is undefined in the browser console. Internet search of the ...
DinoCoderSaurus's user avatar
1 vote

pset8 2018 mashup search

I'd change that to simply $.getJSON("/search", ....) with no reference to Flask.
curiouskiwi's user avatar
  • 18.6k
1 vote
Accepted

How to edit HTML label text and apply CSS using Javascript?

Before you spend too much time researching this on the web, just look closely at the distribution code provided. If I recall correctly, you won't need to change the HTML or CSS files, just the ...
hotwebmatter's user avatar
  • 3,050
1 vote
Accepted

Objects in javascript

Answers 1. Yes. The following function function addMarker(place) { // GPS coordinates for marker var latLng = new google.maps.LatLng(place.latitude, place.longitude); // Create ...
Ibrahim's user avatar
  • 428
1 vote

change icon of marker problem in mashup

You need to use /img/news2.jpg (notice the preceding slash) since img is a subdirectory of public (assuming that news2.jpg is stored in img). You should be able to do it in one line this way: icon: '/...
DinoCoderSaurus's user avatar
1 vote
Accepted

jQuery syntax help

It is an object method. See getJSON api doc especially The jqXHR Object section. This article on jQuery chaining explains why it looks like the methods are "not attached to an object".
DinoCoderSaurus's user avatar
1 vote

pset8 - addMarker/showInfo - Uncaught TypeError: Cannot assign to read only property 'gm_bindings_'

Answer: showInfo expects marker and content as arguments, in that order. I was passing them in the wrong order. When you get an error like that, you have to go back and check every little thing!
MrLeo's user avatar
  • 23
1 vote
Accepted

Javascript Timer- Start when Typing Detected

First you need to think about time past. A common logical way to do this is as so: 1) User presses a key - set time of "now" to a variable lets say "start". 2) User stops typing - compare "now" to "...
user7869's user avatar
1 vote
Accepted

How to Redirect Only When a User Clicks Ok on a Popup?

If you want to use the redirect() function provided in pset7 I'm not sure how, but in general you can do it like so: echo "<script type='text/javascript'> if (confirm('Want to redirect?'...
ChrisG's user avatar
  • 7,376
1 vote
Accepted

Pset7 How to Program Popup?

If you want to use the popup window for any browser you probably want to use javascript. The popup window you have above is called a confirmation box. Here is how to use it: function foo() { ...
ChrisG's user avatar
  • 7,376
1 vote

Accessing information from PHPmyadmin using Javscript

This is the answer from Kareem's link. Please do not vote on this. I just want to take this answered question out of the unanswered list. There are actually several approaches to do this. Some ...
i_am_david's user avatar
  • 1,211

Only top scored, non community-wiki answers of a minimum length are eligible