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 7587271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:37:56+00:00 2026-05-30T19:37:56+00:00

I use JQuery AJAX to retrieve some data (title and description). As you can

  • 0

I use JQuery AJAX to retrieve some data (title and description). As you can see I get a json array and loop through the results and out the results in a div tag

        success : function(jsonArray)
        {

            $.each(jsonArray,function(messageIndex,jsonObject)
            {
               $("#results").append(jsonObject.title + " " + jsonObject.description);
             })

        }

The JSONArray contains JSON Objects like so:

title       : test Title 1
description : test Description 1

title       : test Title 2
description : test Description 2

The JSONArray is created by a backend application I have and then the results passed to the client (JQuery AJAX). The backend is also responsible for displaying a button if it can. How can I let the client know whether to show the button or not?

I was thinking of having another JSONObject which has details about the button to show.
For example the JSONObject would be something like

showButton: false
colour    : red
size      : 50px

The problem is that I’m not sure how to represent this in my JQuery AJAX success. Currently all I’m given is a JSONArray that loops through the objects but how will it know that it hits the button json object?

Do I need to make another AJAX call to get the object?

  • 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-05-30T19:37:58+00:00Added an answer on May 30, 2026 at 7:37 pm

    Your current object structure is something like:

    [ { "title" : "...", "description" : "..." } , ... ]
    

    Instead you can have your backend return a structure something like this:

    {
       "data" : [ { "title" : "...", "description" : "..." } , ... ],
       "button" : { "showbutton" : false, "colour" : "red", "size" : "50px" }
    }
    

    Then in your callback function:

    success : function(response) {
       $.each(response.data, function(messageIndex,jsonObject) {
          $("#results").append(jsonObject.title + " " + jsonObject.description);
       });
    
       if (response.button.showbutton) {
          // create button using response.button.colour and response.button.size
       }
    }
    

    (Note that JSON is a string representation used to send the data, but once it’s been parsed and you start using it in your success function it is not JSON or a “JSON object” or “JSON array”, it is just an object or array.)

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

Sidebar

Related Questions

I am starting to use the jquery $.ajax() but I can't get back what
I am using jQuery's $.ajax method to retrieve some JSON from an API. Each
I'm using ajax to retrieve some data from the backend. I get the result
I am currently using JQuery Ajax to retrieve and display some data as follows.
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I am trying to use jQuery's ajax functionality to update data from a web
So I am trying to use jQuery to insert data from an ajax call.
I am trying to use Jquery.ajax() with PUT and DELETE methods and sending some
I have an asp.net user control on which I want to use jquery ajax.
I use jQuery and AJAX to load content from links and forms into a

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.