title: How to process JSON error message
body: <p>I am a complete beginner with JavaScript and jQuery.</p>
  
  <p>When I query my API I will normally get JSON like this:</p>
  
  <pre><code>{
    "soc": 9271,
    "series": [
      {
        "year": 2013,
        "estpay": 370
      },
      {
        "year": 2012,
        "estpay": 430
      }
    ]
  }
  </code></pre>
  
  <p>However if my query is invalid I will get JSON like this:</p>
  
  <pre><code>{
    "error": "Some message here . . . .."
  }
  </code></pre>
  
  <p>So my question is - what is the syntax to detect the error message and then set up an IF / ELSE type of response? i.e. If error message do this.. If no error message do something else.</p>