Uncaught ReferenceError: tt is not defined

Hi everyone, i have this error while i try to build my code: “Uncaught ReferenceError: tt is not defined”.
I state that this code run in my another project. Someone can help me? The code is:

  function getQuery(){
    var btn = $("#search");
    btn.click(function(){
      var query = $("#query").val();
      var map =
          tt.services.fuzzySearch({
            key: "---my key---",
            query: query
          })
              .go()
              .then(function(response) {
                map = tt.map({
                  key: "---my key---",
                  container: 'map-div',
                  center: response.results[0].position,
                  zoom: 12
                });
              });
    });
  }
  getQuery();
1 Like

It is an error when the SDK is not added or imported.

1 Like

Hi maloleps, thanks for the answer. I find a solution, i write here in case anyone has the same problem. I’m going to use wordpress, and this is my Hook in function.php:

the problem was solved by deleting all the elements after my sdk (line 70 and 71), I don’t know why, but it worked

2 Likes

If you are using any script file and getting "Uncaught ReferenceError: x is not defined " which means ‘x’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘x’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘x’.

To solve this error: Load your library at the beginning of all your scripts.

There can be multiple other reasons for this issue:

  • Conflict with Other Libraries
  • Path to your library included is not correct
  • Llibrary file is corrupted
  • Working offline (when you use CDN)