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

  • Home
  • SEARCH
  • 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 807321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:23:02+00:00 2026-05-15T00:23:02+00:00

I have an array: myarr = []; I’m filling it with some values: myarray[‘name’]

  • 0

I have an array:

myarr = [];

I’m filling it with some values:

myarray['name'] = "Me!";

Now I want to transform that array into a set of Key => Value pairs. I though jQuery would do it automatically, but it doesn’t seem to.

$.ajax
({
    type: "POST",
    dataType: "text",
    url: "myurl",
    data: myarr
});

Is there a way to do this or something I’m doing wrong? I get no javascript errors, and no serverside errors other then no POST information at all.

I need the request to be sent as a true POST request. I need to keep the php code simple because sometimes the login won’t be an AJAX call.

I’m now trying the following with an error unexepected token ':'

myarr:
{
    'name':'me'
}

The question has now become: How do I initialize a new javascript object as “blank”, how do I set up mappings, and how do I pass it in an AJAX call?

  • 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-15T00:23:02+00:00Added an answer on May 15, 2026 at 12:23 am

    The data attribute is an object, so it uses notation like so:

    data: { 'Name': 'Me!' }
    

    Not

    data: ['Name':'Me!']
    

    You need to convert your array to an object. You can easily do this in place of an array:

    myData.Name = 'Me';
    myData.OtherProp = 'Something';
    

    Here’s some samples:

    $.ajax({
        type: 'POST',
        dataType: 'text/html',
        url: 'myUrl.php',
        data:
        {
            'Name': 'Me!'
        },
        success: function(data, status)
        {
            // data is the returned response
        }
    });
    

    OR

    var myObject = new Object();
    
    myObject.Name = 'Me!';
    
    $.ajax({
        type: 'POST',
        dataType: 'text/html',
        url: 'myUrl.php',
        data: myObject
    });
    

    Both should get you to the right place.

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

Sidebar

Related Questions

I created my model to be a multiple array myArr[10,10]. Then I want that
I have array in following format. I want to convert it into another format
I have array with int values int[] myArr = (int[]) alItems.ToArray(typeof (int)); index =
So I have an array with a lot of repeat values. myArr = ['yeh','yeh','yeh','hey']
I have the following Python array of dictionaries: myarr = [ { 'name': 'Richard',
I have a JS array that's filled with data as follows: var myarr =
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
When I have array of objects, when I type the name of variable in
I have a string: string str = "hello"; And an array: string[] myarr =
I have a array like this: my @arr = (Field3,Field1,Field2,Field5,Field4); Now i use map

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.