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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:57:31+00:00 2026-05-27T10:57:31+00:00

Say I have this <div id=x data-id=’1′ data-prop1=’peace’ data-prop2=’out’>Text</div> in jQuery i can get

  • 0

Say I have this

<div id="x" data-id='1' data-prop1='peace' data-prop2='out'>Text</div>

in jQuery i can get the data like so

var row = $('#x')

var x = {
    id : row.data('id'),
    prop1: row.data('prop1'),
    prop2: row.data('prop2'),
};

it would be way more convenient if I could do something like this

var row = $('#x');
var x = row.data.serialize();

Anyone know how to do this?

EDIT:

I forgot to mention that var x = row.data() will do the job but there’s all this jquery junk in there.

I want to send the data as part of an ajax request once i’ve got it.

eg,

remove: function (row, g, o) {

if (confirm(o.deleteConfirmation)) {

                    var url = o.deleteAction;
                    var data = row.data();

                    $.ajax({
                        url: url,
                        type: 'POST',
// THIS WORKS                                
//                            data: {
//                                id: row.data('id'),
//                                applicationId: row.data('applicationId')
//                            },
// THIS DOESN'T                                
                        data : data,
                        success: function (result) {
                            g.html(result.Html);
                            methods.rebind(g, o);
                        }
                    });
                }
 }

EDIT : My ‘Working’ Solution

I got it working by killing the jQuery{some number} thing out of the data object

first I grabbed this from here

if (!String.prototype.startsWith) {
    String.prototype.startsWith = function(str) {
        return !this.indexOf(str);
    };
}

Then I had to do this:

var rowData = row.data();

var data = {};

for(var propertyName in rowData) {
    if(!propertyName.startsWith('jQuery'))
        data[propertyName] = rowData[propertyName];
}
  • 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-27T10:57:31+00:00Added an answer on May 27, 2026 at 10:57 am

    You can call .data() with no arguments and it should return an object with all of the element’s attributes:

    var row = $('#x'); // Won't work as your element's ID is invalid, but oh well.
    var x = row.data();
    

    Demo: http://jsfiddle.net/kYf3t/1/


    Can anyone help remove the __proto__ property? I can’t delete it via delete x['__proto__'].

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

Sidebar

Related Questions

Say I have this script $.get('test.html', function(data){ //data }); How can I find a
Say I have jquery code like this: html += '<div class=index>' + item.index +
Let's say I have a template like this <script id=rowTemplate type=text/x-jquery-tmpl> <tr> <a href=${
Say I have a something like this: <div id=myTop> <a href=# data-role=button data-theme=a>one</a> <a
Let's say I have this: <div id=wrapper> <pre class=highlight> $(function(){ // hide all links
Let's say you have the following chunk of code: <div id=container> <someelement>This is any
In my web app, users can input text data. This data can be shown
Say I have a structure like so: <div data-stuff=foo></div> <div data-stuff=foo></div> <div data-stuff=foo></div> <div
So I'm doing some experimenting with PHP/Apache. Let's say I have this code. <div>DIV
I have this Jquery code and i need to add the var data and

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.