title: AJAX doesn't pick up error
body: <p>I'm completely new to JSON, JS and AJAX. I'm used some example codes to progress through my targets. What I don't understand is when the JSON is an error object the success section is still firing. The console shows error where object d is null or a non-object when error is true. What have I done incorrectly? TIA</p>
  
  <p>Result type good:</p>
  
  <pre><code>JSON: {"data":["1","breast","2","wing","3","thigh","4","leg","5","half","6","quarter white","7","quarter dark","9","whole"],"error":false}
  </code></pre>
  
  <p>Result type error:</p>
  
  <pre><code>JSON: {"error":true}
  
  $.ajax({
              type     : 'GET',
              url      : 'getsubtypes2.php',
              data     : dataString,
              dataType : 'JSON',
              cache: false,
              success  : function(data) {          
                  var output;            
                  var d = data.data;
                      var output = "";
                      for (var i = 0 ; i&lt; d.length; i=i+2) {//error gets to this line
                        var count = d[i];
                        var newOption = d[i+1];
                        output += "&lt;option value='"+count+"'&gt;"+newOption+"&lt;/option&gt;";
                      }
                      $('#select3').empty().append(output); 
              },
              error: function(){
              $('#select3').empty();
                      console.log("Ajax failed");
              }
          });
  </code></pre>