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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:06:34+00:00 2026-05-25T00:06:34+00:00

I have an Ajax call (for a HighChartsDB chart) in a WebForm application that

  • 0

I have an Ajax call (for a HighChartsDB chart) in a WebForm application that calls a webservice, which uses a WebRequest to call an MVC action in another application which returns a JsonResult.

I manage to pass the data back to the ajax call but the data I get back is not parsed as a json object but just a string.

My class:

public class CategoryDataViewModel
{
    public string name { get; set; }
    public List<int> data { get; set; }
    public double pointStart { get; set; }
    public int pointInterval { get { return 86400000; } }
}

My ajax function called by the highcharts:

function getBugs(mileId) {
    var results;

    $.ajax({
        type: 'GET',
        url: 'Services/WebService.svc/GetData',
        contentType: "application/json; charset=utf-8",
        async: false,
        data: { "mileId": parseInt(mileId) },
        dataType: "json",
        success: function (data) {
            console.log(data);
            results = data;
        }
    });

    return results;
}

And finally my WebService

public class WebService : IWebService
{
    public string GetData(int mileId)
    {
        string url = "http://localhost:63418/Home/GetWoWData?mileId=" + mileId;
        WebRequest wr = WebRequest.Create(url);

        using (var response= (HttpWebResponse)wr.GetResponse())
        {
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                var objText = reader.ReadToEnd();
                return objText;
            }
        }

    }
}

With this when I console.log(data) on the ajax call I get:

[{\"name\":\"Sedan\",\"data\":[30,30,30,30,35],\"pointStart\":1307836800000,\"pointInterval\":86400000},{\"name\":\"Low\",\"data\":[800,800,800,826,1694],\"pointStart\":1307836800000,\"pointInterval\":86400000},{\"name\":\"Medium\",\"data\":[180,180,180,186,317],\"pointStart\":1307836800000,\"pointInterval\":86400000},{\"name\":\"High\",\"data\":[29,29,29,34,73],\"pointStart\":1307836800000,\"pointInterval\":86400000},{\"name\":\"Truck\",\"data\":[6,6,6,6,13],\"pointStart\":1307836800000,\"pointInterval\":86400000},{\"name\":\"SUV\",\"data\":[-172,-172,-172,-179,-239],\"pointStart\":1307836800000,\"pointInterval\":86400000},{\"name\":\"Convertible\",\"data\":[0,0,0,0,-404],\"pointStart\":1307836800000,\"pointInterval\":86400000},{\"name\":\"Limo\",\"data\":[-7,-7,-7,-8,-214],\"pointStart\":1307836800000,\"pointInterval\":86400000}]

I can’t seem to manage to pass back into a proper Json object. I tried converting it back to my CategoryDataViewModel with this in my webservice:

    var myojb = new CategoryDataViewModel ();
    using (var response = (HttpWebResponse)wr.GetResponse())
    {
        using (var reader = new StreamReader(response .GetResponseStream()))
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            var objText = reader.ReadToEnd();
            myojb = (CategoryDataViewModel )js.Deserialize(objText, typeof(CategoryDataViewModel ));
        }
    }

    return myojb;

But then I get Type 'Test.CategoryDataViewModel' is not supported for deserialization of an array.

  • 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-25T00:06:35+00:00Added an answer on May 25, 2026 at 12:06 am

    Change:

    myojb = (CategoryDataViewModel )js.Deserialize(objText, typeof(CategoryDataViewModel ));
    

    to:

    myojb = (List<CategoryDataViewModel> )js.Deserialize(objText, typeof(List<CategoryDataViewModel>));
    

    and you should be fine. The array will de-serialize to a list no problem.

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

Sidebar

Related Questions

I am using asp.net MVC to develop an application that will have ajax interactions.
I have a little ajax call that calls rails: $.ajax({ type: POST, url: '...',
Greetings, I have a jqueryui autocomplete input that uses an ajax call to populate
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
I have this code that performs an ajax call and loads the results into
I have coded some JavaScript to perform an ajax call in an asp.net application.
I have ajax code for asp.net (non-mvc) to call to a webMethod to get
I have a Ajax call using asp.net scriptmanager. Which behind the scene takes the
I have an Ajax call that currently needs to be synchronous. However, while this
i have an ajax call $.ajax({ url: '<%=Url.Action(SaveDetails,Survey) %>', dataType: 'JSON', cache: false, data:

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.