title: Problem with ajax call, json returns error 500
body: <p>I am trying to return an object / list of objects in Json format to my webpage. When I return it as an object or List of objects I get error code 500. Request URL: localhost:"portnumber"/Home/FindCustomer Request Method: POST Status Code: 500 Remote Address: [::1]:"portnumber" Referrer Policy: no-referrer-when-downgrade.
  When I debug my code I see that the controller returns the List or object filled with data (not null) however the view side cannot parse it properly, I have read a similar post regarding circular references however I dont know if that is causing the problem</p>
  
  <p>Customers class (6 fields - firstname,lastname,address,phone1,phone2,email) extends BasicObj class (1 field - type Guid - Oid)</p>
  
  <p>this is the controller-side code</p>
  
  <pre><code>     List&lt;Customers&gt; cusList = new List&lt;Customers&gt;();
  
          try
          {
              using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
              {
                  CriteriaOperator crit = CriteriaOperator.And(new BinaryOperator("firstname", "test", BinaryOperatorType.Equal));
                  Customers cust = uow.FindObject&lt;Customers&gt;(crit);
                  cusList.Add(cust);
              }
          }
          catch (Exception ex)
          {
              return Json("Error");
          }
  
          if (cusList.Count == 0)
          {
              return Json(null);
          }
  
          else
          {
              //return Json(cusList);   doesnt work, causes error 500
              //return Json(cusList[0]);   also doesnt work, same error 500
  
              //return Json(new
              //{
              //    Oid = cusList[0].Oid,
              //    firstname = cusList[0].firstname,
              //    lastname = cusList[0].lastname,
              //    address = cusList[0].address,       this way it works
              //    phone1 = cusList[0].phone1,
              //    phone2 = cusList[0].phone2,
              //    email = cusList[0].email
              //});
  
          }
  </code></pre>
  
  <p>this is the view code (I have commented the for-loop where I can access the list contents one by one)</p>
  
  <pre><code>        $.ajax({
          url: url,
          data: data,
          type: "POST",
          success: function (result) {
              if (result != null) {
                  console.log(result);
  
                  $('#customerTable tbody').empty();
                  //for (var i = 0; i &lt; result.length; i++) {
                      $("#customerTable").append('&lt;tr&gt;&lt;td&gt;' + result.firstname + '&lt;/td&gt;&lt;td&gt;' + result.lastname + '&lt;/td&gt;&lt;td&gt;' + result.address + '&lt;/td&gt;&lt;td&gt;' + result.phone1 + '&lt;/td&gt;&lt;td&gt;' + result.phone2 + '&lt;/td&gt;&lt;td&gt;' + result.email + '&lt;/td&gt;&lt;td&gt;' + result.Oid + '&lt;/td&gt;&lt;/tr&gt;');
                  //}
  
              }
              else {
                  $('#customerTable tbody').empty();
                  alert("Customer not found");
              }
  
          },
          error: function (result) {
              alert("error");
          }
      });
  </code></pre>