Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:39:43+00:00 2026-06-11T22:39:43+00:00

I have a two dimensional JSON array returned from a PHP script via a

  • 0

I have a two dimensional JSON array returned from a PHP script via a jQuery AJAX call. I have been browsing around trying to find out how to loop through each of the rows and display each entry within a div but I am very confused and unsure on how to do it in this particular case.

Here is an example of a JSON returned by the server:

{"location_id":"505","location_name":"University of the Arts London","location_type":"uni","location_num_listings":"22","location_num_users":"187","relevancy":"2"},
    {"location_id":"592","location_name":"London South Bank University","location_type":"uni","location_num_listings":"1","location_num_users":"1","relevancy":"2"},
    {"location_id":"591","location_name":"London Metropolitan University","location_type":"uni","location_num_listings":"47","location_num_users":"185","relevancy":"2"},
    {"location_id":"590","location_name":"University College London","location_type":"uni","location_num_listings":"29","location_num_users":"176","relevancy":"2"},
    {"location_id":"586","location_name":"St George's, University of London","location_type":"uni","location_num_listings":"9","location_num_users":"4","relevancy":"2"},

Here is my script so far:

<script type="text/javascript">
    $("#directory_search_input").keyup(function() {
        $("#directory_search_results").html('');
        var regionvalue = $(this).val();
        var jsonresult;
        var url = '<?php echo site_url('ajax/ajax_default/directory_search')?>';
        $.post(url,{input_val:regionvalue}, function(data) {
            var results = jQuery.parseJSON(data);
            $.each(results, function() {
                $.each(this, function(index, value) {
                    $("#directory_search_results").append(/*Append a new div for each row returned*/);
                });
            }); });

Example desired output:

Location ID: 505,
Location Name: University of the Arts London

Location ID: 592,
Location Name: London South Bank University

etc etc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:39:44+00:00Added an answer on June 11, 2026 at 10:39 pm
    var results = $.parseJSON(data);
    $.each(results, function(i, result) {
        $("#directory_search_results").append('<div>Location ID: '+result.location_id+' Location Name: '+result.location_name+'</div>');
    });
    

    ​JSFiddle Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two-dimensional array which I get back as JSON from a call.
I have a two dimensional JSON array where each element contains several attributes. The
I'm trying to encode a two-dimensional PHP array to JSON with json_encode() and I'm
I have a two dimensional array in php and I want to get the
I have a two dimensional array in PHP that prints the index of the
I have a two-dimensional array. When I print/dump this I get the following My
I have a two dimensional array with the following output Array ( [0] =>
I have a two dimensional array public class TwoDimensions { public static void main(String[]
I have the following as two ways to declare a two dimensional String array.
I have the following three arrays and need to create a new two-dimensional array

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.