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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:21:23+00:00 2026-06-14T04:21:23+00:00

_postData : function () { var fieldName = day; var day = /*returns an

  • 0
_postData : function ()
{
    var fieldName = "day";

    var day = /*returns an object from the back end business service*/

    var value = day.getValue();

    if (value)
    {
        return {
            fieldName : value
        };
    }
}

The problem is, even though fieldName is actually “day”, when the JSON payload gets returned and printed, I am seeing literally:

{
   fieldName: "16"
}

So for some reason that variable’s name is being printed, not it’s actual string value. What I want is:

{
   day: "16"
}
  • 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-14T04:21:25+00:00Added an answer on June 14, 2026 at 4:21 am

    This is not JSON, it’s Javascript object literals. And when you put a symbol on the left hand side of a property in a Javascript object literal, that is used as the property name, not any string that the variable of that name might evaluate to. In other words, {fieldName: 16} is exactly equivalent to {"fieldName": 16}

    Instead of doing this:

    return {
         fieldName : value
    };
    

    You could do something like this:

    var obj = {};
    obj[fieldName] = value;
    return obj;
    

    In the second one, if fieldName is a variable containing a string "foo", then the resulting object will look like {foo: 16}

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

Sidebar

Related Questions

I'm writing a simple function that split binary/post-data/html from a HTTP response. The HTTP
Is there a native PHP function for rejecting invalid $_POST data from simple text
Given code like this from a node.js neophyte like me: require('http').createServer(function( req, resp )
il give an example document.ready(function() { $(#Show).bind(click, function() { var F = Function2(); if
I have this code just to send data from already loaded jqGrid: jQuery(#bedata).click(function(){ //Function
$('.removeItem').live('click',function(){ var postData = {}; $(this).closest('tr').find('.tableRow'){ var keyPrefix = 'data[' + index + ']';
I would like to get POST data sent to page controller in init() function
I need to obtain postdata from a form and send it via ajax .
I am triggering jqgrid reload on button click and also resetting the page value
I'm using MVC web Api for RESTful purpose. My controller methods return serialized Json

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.