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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:45:52+00:00 2026-05-29T10:45:52+00:00

I am using jQuery 1.7.1. and I have the following question/problem: The code has

  • 0

I am using jQuery 1.7.1. and I have the following question/problem:

The code has as follows:

var accountObject = new Object();
accountObject.account = new Object();
accountObject.account.sas = [];

$.ajax({
    type: "PUT",
    url: "/a/2",
    data: accountObject,
    dataType: "html",
    success: function(msg) {
        alert_user("Successfully saved the selected session attributes as defaults");
    },
    error: function(msg) {
        alert_user(msg);            
    }
});

The problem is that, due to the fact that I set accountObject.account.sas to an empty array, the data arrives completely empty at the server, as:

{}

where it should have been:

{ "account": { "sas": [] } }

When I put some entries in the sas property of account then everything is ok. For example, if I put the string “1”, “2” and “3” as an array ["1", "2", "3"] then I get on the server:

{ "account": { "sas": [ "1", "2", "3" ] } }

Does anybody know why this is so?

Thanks in advance
Panayotis

  • 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-29T10:45:52+00:00Added an answer on May 29, 2026 at 10:45 am

    The problem is that an empty array cannot be properly represented in a query string. When you pass the object hierarchy to data, jQuery will attempt to convert it to a query string, but can’t figure out what to do with an empty array.

    The reason why 1.4.4 seemed to return an empty string whenever it got passed the same hierarchy was that it attempted to pass the key to the query string without a value, the result of which would be like: ...&property=&. This is by default interpreted as an empty string in most server environments.

    I personally consider the behavior of 1.7.1 correct, because it forces the developer to check for parameter existence instead of mucking the type of the parameter.


    Some notes about various things mentioned here

    • traditional: true is completely wrong, since it can never handle object hierarchies. What you get instead is: ...&key=[object Object], which is javascript’s toString() default result for all objects.

    • JSON.stringify assigned to data will result in the entire thing passed as JSON to the query string, unless you combine it with processData: false, in which case you need to deserialize into meaningful objects “by hand” on the server side. It’s generally a useful option, but overkill in this case where a simple check would presumably have things working with minimal hassle.

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

Sidebar

Related Questions

I have a small question about using jquery. I have the following code: <html>
I have the following snippet of code (I'm using jQuery 1.4.2): $.post('/Ads/GetAdStatsRow/', { 'ad_id':
I'm using jQuery with rails and have the following piece of code $('#related').html(<%= render
I have just started using jQuery and although following code gets the job done,
I have the following ListView in which I am using the JQuery UI sortable
How do you rotate an image using jQuery-rotate plugin? I have tried the following
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I am having an odd problem with jQuery 1.5.2 in Chrome. I have code
I have the following code that works: @for (var index = 0; index <
I'm making a horizontal scroller using jQuery. I have it working using the following

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.