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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:16:39+00:00 2026-05-20T13:16:39+00:00

I return this json from the server: { Id: 0, Name: ko.observable(‘New Product’), PurchasePrice:

  • 0

I return this json from the server:

{
    "Id": 0,
    "Name": ko.observable('New Product'),
    "PurchasePrice": 0.0,
    "DownPayment": 0.0,
    "TotalPayment": 0.0,
    "MortgageInsurance": 0.0,
    "PurchaseOrRefinance": null,
    "Client": null,
    "MonthlyCosts": null,
    "ClosingCosts": null,
    "FirstLien": null,
    "SecondLien": null
}

I retrieve it using jQuery.getJson like this:

function addProduct(){
    $.getJSON('@Url.Action("GetNewProduct","Product")',function(data){
        viewModel.products.push(data);
    });
    viewModel.productSaved(false);
    viewModel.product(products[products.length - 1]);

}

However, it seems as if the code never runs. This only happends when I return the function in the json, if I remove the function everything runs fine. Is there a way to work this out?

  • 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-20T13:16:40+00:00Added an answer on May 20, 2026 at 1:16 pm

    Parsing your data fails since

    {"Name":ko.observable('New Product') }
    

    isn’t actually JSON. You can pass only basic data such as strings/numbers/objects via JSON.
    See http://www.json.org/

    You may consider calling jQuery.ajax() with dataType set to ‘script’.

    Otherwise you need to initialize your variables within your callback function or in the server code, which might even be a cleaner aproach.

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

Sidebar

Related Questions

I'm trying to return json content read from MySQL server. This is supposed to
I have following array return from server side: [json] => Array ( [0] =>
I just simply want to return a JSON object (using ajax) from my server
i need to return a JSON with this format: {answers: [{id: 93, value:Ahstron}, {id=94,
I'm making call to Alfresco Webscripts which return JSON. I do this using GET
I have a problem mapping a Json object recieved from the server into a
jqGrid tree nodes are read from server using json data. Click in node reads
I'm new to regex and I'm trying to grab the JSON response from a
If I have something like this from the server side, from a fetch: array(1)
I'm not sure if return *this is the only way we could return an

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.