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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:40:58+00:00 2026-05-20T20:40:58+00:00

I write a web site with jquery and lot of ajax request to get

  • 0

I write a web site with jquery and lot of ajax request to get data for table and ask data modifications with PHP/MySql on server side.

Currently, I use id attribute to store the id of the field of the table (which is an autoincrement int value).
And it works fine.

BUT I have recently learned that id should be unique (and start with a letter…).
AND I have different tables that could have the same id value (for different sql table)
Then I am not html (nor xhtml) compliant…

How could I correct my code ?

  • By using .data() function of jQuery ?
  • An hidden html element with the id as value (<span class="id">3</span>) ?
  • Other solution ?

Additional informations:
I have wrote a widget to manage my tables.
To add a new row, I do:

    row = $('<div class="row" id="'+item.id+'"/>');
    [...] // I add fields to my row
    row.appendTo(tableData);// tableData is the html element where rows are

When a field element is changed, I trigger an event to the table that will ask the modification to the server with the right id:

$(e.target).closest(".row").attr("id")
  • 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-20T20:40:58+00:00Added an answer on May 20, 2026 at 8:40 pm

    If you are able to use jQuery 1.4.3 or greater look at using the html 5 data-* attributes. jQuery 1.4.3 will automatically use those data- attributes and place them in the .data() collection on the element.

    Example:

    <table>
      <tr data-rowId="1">
    
      </tr>
    </table>
    

    $("tr:first").data("rowId") would print 1

    This method would also allow you to store json objects as well.

    <table>
      <tr data-row='{"Id" : 1, "Name": "Smith"}'>
    
      </tr>
    </table>
    

    And than in your data()
    var row = $("tr:first").data("row")
    You can reference row.Id and row.Name

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

Sidebar

Related Questions

I write a simple OLAP viewer for my web-site. Here are the classes (abstract
I'm write installer for my web site. Installer creating application pool, virtual directory and
I need to write a forum application for a friend's web site. I want
Here's the specs: ASP.NET 3.5 using ASP.NET AJAX AJAX Control Toolkit jQuery 1.3.2 web
I'm trying to renew my company intranet using jquery, ajax and php. General aspect
OK i will write as clear as possible it's an e-commerce web site and
Alright, so I have some jQuery code that will send an AJAX request to
In my web site I've multiple calls of the jquery function load(). We can
I'm working on a web site that uses the jquery animate function to expand
Please, I'm a newbie in PHP, and created my web site, with a text

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.