I'm struggling through the last pset! I managed to get the markers on the map, and got an info window working with just a placeholder in, (now removed) but now I'm stuck on getting the Ajax call for 'articles' to work. I'm getting an 'internal server error 500' and it seems to be the arguments I'm passing to the Ajax call, but I've tried every combination I can think of & I really can't make it work!!! I saw a question with the same problem, my 'articles' route also works when I use the suggested test, feeding in 'geo=' + a postal code, so I assumed that the parameters should be 'geo' and 'place.postal_code' as per the lat & long arguments I've used for the markers...am I missing something??! Any help would be very much appreciated! Here's my code (and I've just added the error msges too...):

enter image description here

 * Adds marker for place to map.

function addMarker(place)
{var myLatLng = {lat:place.latitude, lng:place.longitude};

var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    label: {
        color: 'black',
        text: place.place_name,
    icon: {
        labelOrigin: new google.maps.Point(11, 50),
        url: 'https://maps.google.com/mapfiles/kml/pal2/icon5.png',
        size: new google.maps.Size(30, 60),
        origin: new google.maps.Point(0, 0),
        anchor: new google.maps.Point(11, 40),


var parameters = { geo:place.postal_code };

$.getJSON(Flask.url_for("articles"), parameters)
    .done(function(data, textStatus, jqXHR){

    //check if getJSON is working...

    //create ul of titles with links to add to div in showInfo as 'content' 

    google.maps.event.addListener(marker, 'click', function(){
    // call showInfo 
    showInfo(marker, content);      





1 Answer 1


One sure way to get this error is to send a numeric argument to lookup. You can try this in python command-line:

>>> from helpers import lookup
>>> lookup(6540)

It returns a TypeError. (If you cast it to a string as with lookup(str(6540)) you will get results).

I suspect places.postal_code is defined as a numeric (because of the query string geo=6540). Conventional wisdom says it should be TEXT. It preserves leading 0 in US postal codes, it handles international postal_codes, and generally speaking, it makes the functions in application.py easier to write.

Regardless, make sure the lookup argument is a string, not numeric, in articles.

  • Thank you again! I think though that it is a string - I cast it deliberately because I'd read that - so my code from articles in application.py finishes with: geo = str(request.args.get("q")) / result = lookup(geo) / return jsonify([result]) - wouldn't that do it? (sorry for the format)
    – CallyB
    Apr 7, 2017 at 21:58
  • oops - it's really late here, sorry - places.postal_code you meant! Yes, I had that as an integer, but I just changed it to text and I'm getting the same error msg still....
    – CallyB
    Apr 7, 2017 at 22:04
  • Yayy! Thank you again DinoCoderSaurus (great name BTW!) - it didn't make sense that your suggested solution didn't work - I did have places.postal_code as text so why didn't changing it help?! So I closed and reopened my browser just to see and now it works (no idea why but I'll take it!!!) You are a life saver!!!
    – CallyB
    Apr 8, 2017 at 7:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .