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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:04:10+00:00 2026-06-11T09:04:10+00:00

I want to pass label/value pair in Ajax .POST but cannot find any solution.

  • 0

I want to pass label/value pair in Ajax .POST but cannot find any solution. Ajax .POST normally send id/value pair but I cannot change my id and would like to send labels/value pair instead. I have provided partial form. Any help please.

        $.ajax({
            url:"allfields.php",
            type:"POST",
    //      dataType:"json",
            data: $("#frmRequest").serialize(),
            success: function(msg){
                alert("Form Submitted: "+ msg);
                return msg;

              },
             error: function() {
            alert('Error occured');
             }
        });

<body>
     <form id="frmRequest" name="frmRequest" >

                <div class="clearfix" id="idRequestDetails"  >
                    <table width="809" border="0" id="tbl_data_1_1_1_1__" summary="Profile">
                      <tr>
                        <th width="156" scope="col"><label class="labelrequest" for="txtProfileName1__">Name</label>
                        </th>
                        <th width="74" scope="col"><label class="labelrequest" for="txtProfileUserID1__">User ID</label></th>
                        <th width="131" scope="col"><label class="labelrequest" for="txtSiteCost1__">Site Cost Centre</label></th>
                         <th width="182" scope="col"><label class="labelrequest" for="txtDetail1__">Additional Details</label></th>
                      </tr>
                      <tr>
                        <td><input type="text" name="txtProfileName1__" id="txtProfileName1__" tabindex="100" /></td>
                        <td><input name="txtProfileUserID1__" type="text" class="clearfix" id="txtProfileUserID1__" tabindex="110" size="8" /></td>
                        <td><input name="txtSiteCost1__" type="text" id="txtSiteCost1__" tabindex="220" size="8" /></td>

                        <td><textarea name="txtDetail1__" rows="1" id="txtDetail1__" tabindex="240"></textarea></td>
                      </tr>
                    </table>
                  </div>
        </body>
  • 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-11T09:04:12+00:00Added an answer on June 11, 2026 at 9:04 am

    Here is an example:

    HTML

    <form>
        <label>Label1</label><input type="text" value="1">
        <label>Label2</label><input type="text" value="some">
    </form>
    

    jQuery

    var dataToServer = [];
    $('form label').each(function() {
        dataToServer.push({
            label: $(this).text(),
            value: $(this).next().val()        
        });
    });
    
    console.log(data);
    // output
    // [ {label: 'Label1', value: '1'}, {label: 'Label2', value: 'some'}]
    

    Working Example.

    Hope this can give you some guideline.

    According to commnet

    AJAX part

    $.ajax({
        url: "allfields.php",
        type: "POST",
        dataType:"json",
        data: dataToServer,   // send above data here
        success: function(msg) {
            alert("Form Submitted: " + msg);
            return msg;
        },
        error: function() {
            alert('Error occured');
        }
    });
    

    Final shot

    $('#submit').on('click', function() {
        var dataToServer = [];
        $('#frmRequest label').each(function(i, el) {
            var temp= {},
                label = $(this).text(),
                value = $('#' + $(this).attr('for')).val();
            temp[label] = value;
            dataToServer.push(temp);
        });
        console.log(dataToServer);
    });
    

    See the console output

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

Sidebar

Related Questions

I want to store integer value in label and to pass to another form.
I want to pass an ImageIcon instance by value as we know that by
I want to pass data from second tab to first tab using delegates.But delegate
i made 2 views and i want to send text of label on main
I am creating a code in which i want to pass integer value for
I want to change the text of a label when i choose a new
What I want to do is pass a the value of the fields in
I would like to send a label value whith the querystring. How do I
I want to change the value of default empty_label of field. So I did
HI - I have a value in a UILabel and I want to 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.