title: Javascript and Jquery: Uncaught TypeError: Cannot read property 'length' of undefined
body: <p>Currently I'm writing a site where one feature is to allow the user to type in the name of a card (the game's Hearthstone), and add it to a deck on the site. I'm using JSON data from 
  <a href="http://hearthstonejson.com/json/AllSets.json" rel="nofollow">http://hearthstonejson.com/json/AllSets.json</a> , but I'm having trouble querying that data.</p>
  
  <p>Right now I have:</p>
  
  <pre><code>// On user submission, searches for the inputted card name and places it into
  // the deck if a match is found
  $("#cardSearch").submit(function(){   
      card = $("#userInput").val();
      console.log("Card searched: " + card);
      $.getJSON("http://hearthstonejson.com/json/AllSets.json",function(cards){
         // cards = JSON.parse(cards);
          console.log(cards);
          $.each(cards.name, function(key, val){ 
              if (val.name == card) {
                  console.log("Success, I found :" + val.name);
                  return;
              }
          });   
      }   
      );
  });
  </code></pre>
  
  <p>My error is Uncaught TypeError: Cannot read property 'length' of undefined , referencing line 631 from the latest version of jquery.</p>
  
  <p>I thought that maybe I had to parse the data, as you can see with the commented line of code in the middle. But, when I add that line, I get a different error:</p>
  
  <p>Uncaught SyntaxError: Unexpected token o.</p>
  
  <p>I'm not sure where to proceed. </p>
  
  <p>Thanks for the help - I'm pretty new to this!</p>