Am new to cartodb and am following this tutorial (http://docs.cartodb.com/tutorials/create_map_cartodbjs.html) on how to create a map.

When Implement the sql query, i get an error on the console saying "Failed to load resource: the server responded with a status of 400 (Bad Request)". I have included the screenshot of my browser displaying the error.

 var subLayerOptions = {
  sql: "SELECT * FROM my_cartodb_table_title WHERE city = 'CITY X' "

cartodb.createLayer(map, layerUrl/*, {no_cdn: true}*/)
.done( function(layer) {
  data_layer = layer.getSubLayer(0);
.error( function(err) {
  console.log("some error occurred: " + err);


What could be the problem?

Error log in the console

1 Answer 1


The request of your tiles is not being done correctly: check that the URLs you're showing include undefined as identifier.

This is probably caused by using CartoDB.js 3.11.23, which is a quite old version at the moment. The last version of 3.11 is 3.11.38 at this moment and it can be obtained with these URLs.

http://libs.cartocdn.com/cartodb.js/v3/3.11/themes/css/cartodb.css http://libs.cartocdn.com/cartodb.js/v3/3.11/cartodb.js

3.11 for HTTPS:

https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.11/themes/css/cartodb.css https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.11/cartodb.js

Right now, the last CartoDB.js release is version 3.15, whose URLs are the following ones:



3.15 for HTTPS:



If you're using the non-versioned URL for CartoDB.js (http://libs.cartocdn.com/cartodb.js/v3/cartodb.js ), you need to be aware that this non-versioned URLs are deprecated and should be no longer used, but you need to specify the version you want in the URL.

  • If this response solved your issue, could you mark it as answered so that other users could check it? :)
    – iriberri
    Commented Jul 9, 2015 at 10:51
  • Hi, again. In my css code, just after my sql statement I added this line cartocss: "#table_title{marker-fill : #6d1948; marker-width: 5; marker-line-color: white; marker-line-width: 1; }" and I get an errors in the console. 1. Uncaught SyntaxError: Unexpected identifier 2. Uncaught ReferenceError: init is not defined I have declared the function init here <body onload="init()"> What could be the problem. Many Thanks!
    – andy
    Commented Jul 9, 2015 at 15:50
  • If it's a different question, could you open it as a new one? :)
    – iriberri
    Commented Jul 9, 2015 at 16:55
  • Okay, Will do :-)
    – andy
    Commented Jul 9, 2015 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.