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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:27:39+00:00 2026-05-29T11:27:39+00:00

The excerpt below is part of a .ajax() function I’m using to pull data

  • 0

The excerpt below is part of a .ajax() function I’m using to pull data from a database. The database is queried using PHP and the output sent back in JSON format. Only 1 row of data is returned by the function.

success: function(data) {
    for(var key in data) {
        $("#formTable tr").find("td:eq(1)").text(data[key]);                            
    }
}

I have an HTML table on the page which is split into two columns. The left column has field labels, the right column is empty.

I would like to cycle through my JSON reply for each key/value pair. I would like to insert the value into the right hand column table cell. The code should cycle through until all key/value pairs have been output onto the next table row, into the next right hand table cell.

The code above selects the second column table cell but inserts the last JSON value into all cells instead of each value going into its’ own table cell in the column.

I think if I can get the selector right this will work, I’m just not sure what that should be..

Thanks.

  • 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-29T11:27:39+00:00Added an answer on May 29, 2026 at 11:27 am

    You are basically selecting all the rows of the table and second td from the whole set of table rows in each iteration so it isn’t working as expected.

    Assuming that the json response has one to one mapping of keys and the field labels in the table you can try this.

    success: function(data) {
        var fieldCount = 0,
            $tableRows = $("#formTable tr");
        for(var key in data) {
            $tableRows.eq(fieldCount++).find("td:eq(1)").text(data[key]);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is an excerpt from an .svg file (which is xml): <text xml:space=preserve style=font-size:14.19380379px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:DejaVu
Below is excerpt from Google Developer Console typeof Object // type of Object is
I have a database field with data like the examples below: FEE 200 A
Below is a simple database class, well its part of a class, I stripped
The snippet of the PHP script below works for the most part... except for
Excerpt from a book: A float value consists of a 24-bit signed mantissa and
Excerpt from my JavaScript console: > 0 in [1, 2] true Why?
This is an excerpt of code from a class I am working with in
Here is a code excerpt from AspComet project that works with Autofac. public MessageBus(IClientRepository
Here's an excerpt from a book I'm reading about application design with MVC: Ideally,

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.