Skip to main content
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.7k
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
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.7k
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
  • 21k
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
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
  • 21k
1 vote

The Ajax introduced on lecture and in the Shorts Video are very different: will be helpful to know why?

Thanks for the question. That short is no longer relevant to the lecture so we've removed it.
curiouskiwi's user avatar
  • 18.7k
1 vote

Trivia Lab 8 Week 8 - Issues with Free Answer Question

In line 33 I misspelled document as "doctument".
Raheel A'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
  • 111
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.7k
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
  • 21k
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
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.7k
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

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