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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:05:04+00:00 2026-05-26T15:05:04+00:00

Hi every one I need to send an array as the data of a

  • 0

Hi every one I need to send an array as the data of a post request using $.ajax, this array is a key value array,
e.g

fields['BrandName'] = "Fiat,BMW"
fields['year'] =  "2004,2005"

i tried this

$.ajax({
    type: "POST",
    url: url,
    dataType: 'json',
    data: {'adfields[]': fields},
    success: function(data){
        alert("passed");                
    },
    error: function(data, status){
        alert("error has occurred");
    }
});

but it doesn’t work, I watch the request using wireshark, but nothing gets sent in the request, something else when I try to do fields.length .. i get zero although fields[‘BrandName’] is defined and has a value
Any 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-05-26T15:05:04+00:00Added an answer on May 26, 2026 at 3:05 pm

    Further to alFReD’s answer, two ways you can code your fields variable as an object such that the key/value properties will be passed in your Ajax call:

    // declare empty object
    var fields = {};
    // then add keys and values with the syntax you already had
    fields['BrandName'] = "Fiat,BMW";
    fields['year'] =  "2004,2005";
    
    // OR
    // declare in one statement
    var fields = { 'BrandName' : "Fiat,BMW",
                   'year' : "2004,2005" };
    

    Note that the curly braces {} only apply in the initial declaration: once your object has been created you use square brackets to access the properties. Or, dot notation:

    fields.BrandName = "Fiat,BMW";
    

    (Dot notation only works if the keyname follows the same rules as other JS identifiers, e.g., no spaces, not starting with a number, not a reserved word, etc.)

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

Sidebar

Related Questions

We're often faced with the need to send a data file to one of
Hello every one I want to send ajax call and on success I want
I prepare to develop one heartbeat program, which need to send udp packet every
I'm using an online form at one of my web sites. Every mail sent
The scenario is this: My company has 2000 customers, and we need to send
I need to serialize an object using the BinaryFormatter with .NET 4.0 and send
I need to check every five minutes if 4 servers are online from one
I am doing an ajax request through post that contains a forms variables. the
I have a javascript array that I am using as a data source in
I am developing one GPS Application. Which will send the location data to server

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.