title: AJAX call display api key and values in html div
body: <p>hope you can help me.</p>
  
  <p>I am trying to figure out how to display api json key and value data on my html webpage as (formatted css). Ajax call hooking into a nodejs server and getting back data.
  I am getting successful ajax call and outputting on console.log, but coming back with [object object] on my webpage.</p>
  
  <p>Api data is structured like this</p>
  
  <pre>`
  {
      "error": false,
      "model" : [
      {
          "key1": "value1",
          "key2": "value2",
          "key3": "value3",
          "key4": "value4",
          "key5": "value5",
          "key6": "value6",
          "key7": "value7",
          "key8": "value8"
      },
      {
          "key1": "value1",
          "key2": "value2",
          "key3": "value3",
          "key4": "value4",
          "key5": "value5",
          "key6": "value6",
          "key7": "value7",
          "key8": "value8"
      }
  ]
  }`
  </pre>
  
  <p>Function looks like this</p>
  
  <pre>`
  var _t = this;
  var modelUrl = "/searchModel";
  (api key is already passed)
  
  
  
  this.searchModelEvent = function (e) {
  
      e.preventDefault();
      var $m = $(this);
  
      var _serial = $m.find(".serialNum").val();
  
      var modelData = { apikey: apikey,id: _serial };
      modelData = JSON.stringify(modelData);
  
      console.log(modelData);
      $.ajax({
          type: 'POST',
          contentType: 'application/json',
          dataType: 'json',
          data: modelData,
          url: modelUrl,
          success: function(data) {
          if (data.error) {
          _t.errorState();                    
          } else {
          console.log("SUCCESS!!@#! \n");
          _t.loginModelState(data);
      }   
  
  },
  
  }); 
  
  };
  
  this.loginModelState = function (data) {
          var _model = data;
  
          for (var _i in _model) {
          var _output="";
          if(_model[_i] instanceof Object){
  
          for(var _x in _model[_i]){
  
          console.log(_model[_i][_x]);
  
          _output+=""+_x+"<br>"+_model[_i][_x];
  
          } 
      }   
          _output+="";
          $('div').html(_output);
      }
  };//end`
  </pre>