title: Create HTML table out of object array in Javascript
body: <p>I am calling a web Method from javascript. The web method returns an array of customers from the northwind database. The example I am working from is here: <a href="http://www.asp.net/learn/ajax/tutorial-05-cs.aspx" rel="nofollow noreferrer">Calling Web Services with ASP.NET AJAX</a></p>
  
  <p>I dont know how to write this javascript method: <strong>CreateCustomersTable</strong></p>
  
  <p>This would create the html table to display the data being returned. Any help would be appreciated.</p>
  
  <p>My javascript</p>
  
  <pre><code>function GetCustomerByCountry() {
    var country = $get("txtCountry").value;
    AjaxWebService.GetCustomersByCountry(country, OnWSRequestComplete, OnWSRequestFailed);
  }
  function OnWSRequestComplete(results) {
      if (results != null) {
          CreateCustomersTable(results);
          //GetMap(results);
      }
  }
  function CreateCustomersTable(result) {
      alert(result);
  if (document.all) //Filter for IE DOM since other browsers are limited
  {
     // How do I do this?
      }
  }
  else { 
  $get("divOutput").innerHTML = "RSS only available in IE5+"; }
  }
  </code></pre>
  
  <p>My web Method</p>
  
  <pre><code>    [WebMethod]
      public Customer[] GetCustomersByCountry(string country) 
      {
          NorthwindDALTableAdapters.CustomersTableAdapter adap =
             new NorthwindDALTableAdapters.CustomersTableAdapter();
          NorthwindDAL.CustomersDataTable dt = adap.GetCustomersByCountry(country);
  
          if (dt.Rows.Count &lt;= 0)
          {
              return null;
          }
  
          Customer[] customers = new Customer[dt.Rows.Count];
          for (int i = 0; i &lt; dt.Rows.Count; i++)
          {
              NorthwindDAL.CustomersRow row = (NorthwindDAL.CustomersRow)dt.Rows[i];
              customers[i] = new Customer();
              customers[i].CustomerId = row.CustomerID;
              customers[i].Name = row.ContactName;
          }
          return customers;
      }
  </code></pre>