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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:55:54+00:00 2026-06-17T15:55:54+00:00

Alright I want to submit a form thru jquery ajax. All the inputs are

  • 0

Alright I want to submit a form thru jquery ajax. All the inputs are in an array and it is multidimensional.

Its a dynamic form that uses the array key as the question id.
The subkey is used for grouping the questions at a question set.

<form name="testing" id="testing" method="post">
    <label>Question 1?</label> 
    <input type="text" name="data[14][1]" id="" class="" value=""><br>
    <label>Question 2?</label> 
    <input type="text" name="data[16][1]" id="" class="" value=""><br>
    <label>Question 1?</label> 
    <input type="text" name="data[14][2]" id="" class="" value=""><br>
    <label>Question 2?</label> 
    <input type="text" name="data[16][2]" id="" class="" value=""><br>
    <label>Question 3?</label> 
    <select name="data[19]" id="" class="">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
    </select><br>
    <input type="submit" value="Submit">
</form>

So that is my example html. Here is my example jquery:

$("#testing").submit(function() { 
           var data = $('input[name^="data\\["]').serializeArray();
                $.ajax({ 
                 type: "POST",
                 url:  "upload.php",
                 data: {internalform: "submit", data: data},
                 dataType : "text",

           success: function(returndata){
            if(returndata == "no") 
             { return false;
             } else {
               alert("clicked 1 " + returndata);
                }
                 } 
                 });    
            return false;
            }); 

Problem is I get this as a return array:

Array
(
    [0] => Array
        (
            [name] => data[14]
            [value] => sd
        )

    [1] => Array
        (
            [name] => data[16]
            [value] => s
        )

)

But I want an array like this:

Array ( [14] => ddd [16] => ddd [19] => 4 ) 

Im sure its simple but I’m missing something. I know why its doing it but I can’t get it the way I want it/need it. Can someone help?

  • 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-17T15:55:55+00:00Added an answer on June 17, 2026 at 3:55 pm

    Try below snippet,I have not tested this but probably it should work.

    Replace var data = $('input[name^="data\\["]').serializeArray(); part with below snippet

    var data = {};
    $.each($('input[name^="data\\["]')​.serializeArray()​, function() {
        data[this.name] = this.value;
    })​;
    

    Try this it will solve the data coming in front issues

    i have worked out this one

    var data = {};
    $.each($('select[name^="data\\["] , input[name^="data\\["]').serializeArray(), function() {
       var vv = this.name.replace(/data/, '' ).replace(/(\[[0-9]\])$/,'');
       data[vv] = this.value;           
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I have a wordpress site, that I want to have a clientportal built
Alright, so I have an image that it's resolution is: 1054X1054. I want to
Alright heres the deal. I have a sports app that i want to update
Alright so I want my users to be able to click a link that
Is it alright to do this? $author = strtolower($_SESSION['valid_username']); I want to enter all
Alright so I have a link that is clicked...once it is clicked I want
Alright, so I have an app that has a custom folder: I want to
Alright so in Java I want to ask the user for a time in
Alright, so I want the user to be able to enter every character from
Alright, here goes. I'm making a very basic app, and I want the user

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.