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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:18:47+00:00 2026-06-01T07:18:47+00:00

Recently, I searched for a good engine to generate charts with Asp.Net Mvc 3.

  • 0

Recently, I searched for a good engine to generate charts with Asp.Net Mvc 3. I finally found FusionChart which have a very nice varieties of chart types.

For helping me creating the xml required to display the chart, I found the project Libero. This project create a level of abstraction between the xml and the object model to define the properties of the graphic.

The project use Mvc2 and I tried to convert it to Mvc3. All the samples works perfectly except one; a sample with ajax call.

In the sample, the controller returns a ContentResult that returns a xml to update the graphic dynamically. The project works perfectly in Mvc2 but not in Mvc3.

Here is the code in the controller:

  public ActionResult GetSalesXmlData(string period, string chartType, string chartTemplate)
  {
     var salesXmlData = this.Content(GetSalesChart(period, chartType, chartTemplate).ToXML(), "text/xml");

     return salesXmlData;
  }

And here is the code in the view:

$.ajax({
    url: "/Home/GetSalesXmlData",
    type: "POST",
    data: { chartType: chartType, chartTemplate: chartTemplate, period: period },
    dataType: "application/JSON",
    success: function (data) {
        Chart01.xmlData   = data;
        Chart01.chartType = chartType;
        Chart01.showChart();
    },
    error: function () {
      alert("XMLHttpRequest=" + XMLHttpRequest.responseText + "\ntextStatus=" + textStatus + "\nerrorThrown=" + errorThrown);
    }
});

When I try to execute this code in Mvc3, I receive this error:

textStatus=parsererror
errorThrown=No conversion from xml to application/json

After searching for a while, I found how to correct my problem in this stackoverflow question.

After reading this post, I changed my controller code to this:

  public JsonResult GetSalesXmlData(string period, string chartType, string chartTemplate)
  {
     var salesXmlData = this.Json(GetSalesChart(period, chartType, chartTemplate).ToXML(), "text/xml");

     return salesXmlData;
  }

And my ajax call to this:

$.ajax({
    url: "/Home/GetSalesXmlData",
    type: "POST",
    data: { chartType: chartType, chartTemplate: chartTemplate, period: period },
    dataType: "text json",
    success: function (result) {
        Chart01.xmlData   = result;
        Chart01.chartType = chartType;
        Chart01.showChart();
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      alert("XMLHttpRequest=" + XMLHttpRequest.responseText + "\ntextStatus=" + textStatus + "\nerrorThrown=" + errorThrown);
    }
});

My question is: Why after converting my project from Mvc2 to Mvc3, I must change the result returns by the controller from ContentResult to JsonResult and in my view, the dataType value from application/JSON to text json?

Thank you for your time.

  • 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-01T07:18:49+00:00Added an answer on June 1, 2026 at 7:18 am

    In your original example, you were instructing jQuery to parse the response as JSON even though it was XML. If you upgraded from an older version of jQuery to a newer one as part of the MVC upgrade process, that would explain the parser error. Older versions of jQuery were fairly fast and loose about parsing AJAX responses, but later versions have begun using JSON.parse when jQuery believes the response to be JSON or you explicitly tell it to treat them as such.

    Your newer version works around this by taking the XML and JSON-serializing that XML. While that technically does work, it has added an inefficient layer of redundant serialization.

    Does your original approach work if you change the dataType to text/xml?

    Speaking of efficiency, have you considered using JSON instead of XML? FusionCharts appears to support that. Then, you could avoid the XML altogether, use a more compact serialization over the wire, and take advantage of the browser’s native JSON.parse method to more efficiently unpack the response too.

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

Sidebar

Related Questions

I haven't searched real hard recently but in the past I have searched high
I recently came across this interesting term and searched on Net to know more
I have good knowledge on C++ (not C) and recently bought a Symbian-based phone.
I recently found out about java.util.Properties , which allows me to write and read
I've searched for a potential answer to my question below, and have not found
I started learning asp.net recently and when I try to add a script manager
I have been recently assigned a task in which I need to create a
Motivation Recently I searched for a way to initialize a complex object without passing
Recently I asked this question: Find Common Values in several arrays, or lists VB.NET
Recently i saw an open source javascript library have a line like : style

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.