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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:31:40+00:00 2026-06-14T06:31:40+00:00

I usually pass data through .post() like this: $.post( /ajax.php, $(#form).serialize(), function(responseJSON) { console.log(responseJSON);

  • 0

I usually pass data through .post() like this:

 $.post(
    "/ajax.php",
    $("#form").serialize(),
    function(responseJSON) {
        console.log(responseJSON);
    },
    "html"
);

Within my form "#form" I usually have a hidden input with the name “id” which holds a value to the id of the item I want to run queries on.

What I want to do is take out that hidden input and add in a data-id="$id" attribute in my submit button and have the jQuery function extract the data from there and send that along with the other #form fields.

In simple terms what I’m asking is how do I pass along $('#form').serialize() along with $('#button').data('id') over to my back end all in one $.post() function?

  • 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-14T06:31:42+00:00Added an answer on June 14, 2026 at 6:31 am

    try this

    var data = $("#form").serialize() + '&data-id=' + $('#button').data('id');
    $.post(
        "/ajax.php",
        data,
        function(responseJSON) {
            console.log(responseJSON);
        },
        "html"
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that looks something like this: <form id=uploadForm name=uploadForm method=post enctype=multipart/form-data>
Ok, I usually do this in reverse, post a specific data set, then expect
I'm trying to save a data in a simple form through Hibernate using struts
Frequently when I work on AJAX applications, I'll pass around parameters via POST. Certain
I usually pass data between my web servers (in different locations) using HTTP requests
I'm wondering why all frameworks pass data to Views by an array, usually called
I use something like below to pass information from one unbound form to another
I usually use the interface Parcelable to pass data from one Activity to another.
To be able to unit test my C++ code I usually pass the constructor
When I have to render textarea content to the front end I usually pass

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.