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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:06:06+00:00 2026-06-06T03:06:06+00:00

I need an advice on how to write my website. In my DB I

  • 0

I need an advice on how to write my website.

In my DB I have some data that I want to dynamically load into different frames on my website. Question is: Where do I convert the raw data to HTML-code?

I currently see the following options:

  • convert it to HTML in a PHP function and load that via Ajax on my page
  • Get the raw data via Ajax and convert it in Javascript to HTML-code
  • Write a HTML-Table manually and then insert the data into it via Ajax

All three of those options have their disadvantages – for instance I need to be able to select the table rows with jQuery which I don’t know how to do when the table HTML-code is loaded into the page with Ajax… to write the HTML-table manually would solve that problem, but the table needs to have a variable number of rows.

Are there options that I haven’t thought about yet? Any other advice for me?

  • 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-06T03:06:08+00:00Added an answer on June 6, 2026 at 3:06 am

    It depends, but I would go with 1 or 2 unless the number of rows and columns is constant.

    Option 1 has the advantage that generating HTML in PHP can be done more pragmatically than in Javascript, so if you need to make something really quick, or you have a template system in place on the server side already, try option 1. A huge downside of this approach is that you have to trust the server to send ‘sane’ HTML; if you don’t use SSL for the AJAX calls, a simple MITM attack can easily inject exploitable XSS code, and if the server for some reason sends broken HTML, it is hard to detect and probably impossible to recover from.

    So normally, I’d prefer option 2. I wouldn’t even bother with HTML at this point, instead, I’d just manipulate the DOM directly, that is:

    • loop over data rows; for each row, construct a tr element and append it to the table’s body
      • loop over columns; for each row, construct a td element and append it to the tr; use .text() to add content to the cell.

    Example code:

    function fillTable(data) {
        var tbody = $('<tbody/>');
        data.each(function (row) {
            var tr = $('<tr/>');
            tbody.append(tr);
            row.each(function (cell) {
                var td = $('<td/>');
                tr.append(td);
                td.text(cell);
            });
        });
        $('#myTable>tbody').replaceWith(tbody);
    }
    

    This way, you don’t have to worry about HTML encoding (and thus, XSS), because you are injecting DOM nodes directly – the browser won’t do any HTML parsing at all.

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

Sidebar

Related Questions

I have 3 tables, I need advice on how to get data from them.
I need to implement some crypto protocol on C# and want to say that
I need to write a clause into my xslt that says if an element
I need to write some application which will have a couple threads and these
I'd like some advice on passing data from form to form. I need to
I need an advice on how to write a windows service application that would
I'm kind of new to iOS development and need some advice. I have a
I need some advice on how to write a Python program where it gives
I write code in isolation, that is I work for myself. I need some
i need to write a java program but i need some advice before starting

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.