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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:17:38+00:00 2026-06-10T18:17:38+00:00

I am creating form using cakephp form. It is creating form something like this:

  • 0

I am creating form using cakephp form. It is creating form something like this:

<form name='license' action='/some/action' action='POST'>

  <input type="text" id="license0Number" name="data[license][0][number]">
  <input type="text" id="license0Year" name="data[license][0][year]">

  <input type="text" id="license1Number" name="data[license][1][number]">
  <input type="text" id="license1Year" name="data[license][1][year]">

</form>

It is working fine when submitting form in normal form and getting data something like this:

$data = array( 'license' => array( '0' => array( 'number'=>'123', 'year'=>'2000' ),
                                   '1' => array( 'number'=>'321', 'year'=>'2003' )
                                 );

But when I submit same form using jQuery $.ajax() function and posting data with serialize() function. I am getting data something like this on server side.

Array
(
[data%5Blicense%5D%5B0%5D%5Bnumber%5D] => 123
[data%5Blicense%5D%5B0%5D%5Byear%5D] => 2000
[data%5Blicense%5D%5B1%5D%5Bnumber%5D] => 321
[data%5Blicense%5D%5B1%5D%5Byear%5D] => 2003
)

How can I get form data in form of associate arrays when usign jQuery $.ajax() function ?

EDIT:

$('#license_form').live( 'submit', function( event ) {

  var action = '/some/action';
  var data = $(this).serialize();

  $.ajax({

     type: "POST",
     url: action,
     data: data, // form data
     success: function( result ) { alert( result ); },
     error: function() { alert('error'); }
  });

   event.preventDefault();
});

Thanks

  • 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-10T18:17:39+00:00Added an answer on June 10, 2026 at 6:17 pm

    No need to user Low-Level ajax, use $.post shorthand instead.

    Try this:

    $(function(){
    
      $("#submit").click(function(){
         //Since you're talking about POST
         $.post('path_to_php_script.php', {
    
           "license0Number" : $("#license0Number").val(),
           "license0Year"   : $("#license0Year").val(),
           "license1Number" : $("#license1Number").val(),
           "license1Year"   : $("#license1Year").val()
    
    
          }, function(respond){
    
              //Respond from PHP
              //Maybe replace some div with the server respond?
              $("#some_div").html(respond); //optional   
          });
    
       });  
    
    });
    

    You asked for POST ASSOC ARRAY Using jquery,
    so you’ll get that,

    In your php script:

    <?php
    
    print_r($_POST); //will print what you want
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating form elements with Zend (using Zend Studio for Eclipse), I'd like some
I am using cakephp and creating a form <?php echo $form->create('User', array('action' => 'cancel'));?>
I am creating a form using Cake.In the form there is a $this->Form->button($i); element.
what I am doing is creating a form using JSON this form can then
I am creating a select box for a form using this in _form.html.erb <%=
I'm doing this tutorial: http://www.phpeveryday.com/articles/Zend-Framework-Database-Creating-Input-Form-P494.html We are building a simple input form using POST
I'm using this script http://mondaybynoon.com/2009/02/23/creating-custom-form-elements-using-jquery-selects/ to create custom css select boxes in my page.
When creating a form using three20 components with the methodology found in this example
I'm creating a form and using it to get data input to send to
I am creating a form using createuserwizard in asp.This is my code. <asp:CreateUserWizard ID=userwizard

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.