JQuery loop display array name and value

JQuery loop display array name and value

I am trying to build a loop where it will display like this:

Company Name ABC Inc
Mailing Address Springfield ZZ 12345
Phone 1 (555) 555-5555
Fax 1 (555) 555-5556

My current code is not looping for each object just displaying once.

Json Encode output


[{"Company Name":"ABC Inc","Mailing Address":"Springfield ZZ 12345","Phone":"1 (555) 555-5555","Fax":"1 (555) 555-5556","Email Address":" test@test.com"}]


HTML Code

  1. <!-- Company Details -->
  2. <div id="company">
  3. </div>
  4. <!-- /JS Company Details -->
  5. <script type='text/javascript'>
  6. $(document).ready(function () {
  7. /* call the php that has the php array which is json_encoded */
  8. $.getJSON('php/company.php', function (company) {
  9. /* data will hold the php array as a javascript object */
  10. $.each(company, function (company_key, company_val) {
  11. $("#company").append(
  12. '<div class="row">'+
  13. '<div class="col-md-6">'+
  14. '<div class="form-group">'+
  15. '<label class="control-label col-md-4"> Array Name</label>'+
  16. '<div class="col-md-8">'+
  17. '<p class="form-control-static"> Array Value </p>'+
  18. '</div>'+
  19. '</div>'+
  20. '</div>'+
  21. '</div>'
  22. );
  23. });
  24. });
  25. });
  26. </script>
  27. <!-- /JS Company Details -->