Program code
The code is as follows |
Copy Code |
<script type= "Text/javascript" >
$ (document). Ready (function () {
var myChart = new Fusioncharts ("/fusioncharts/fcf_msline.swf", "MyChart1", "720", "300");
Mychart.setdataurl ("/portal/getuserstat");
Mychart.render ("Charts1");
})
</script>
|
Intuition is associated with character encoding. In the browser, the MVC interface data is saved as an XML file, Fusioncharts directly call the XML file is also garbled, and then use UltraEdit Open XML Save as UTF8 with BOM file, the chart shows normal, before and after two XML files:
In order to ensure that the BOM is not in the browser to save the last loss, the HTTP data grab packet, determine the server response when there is no BOM:
Now can be sure because the MVC output of the content of the lack of BOM lead to garbled, how to change it? Find code:
code is as follows |
copy code |
return Content (str," Text/xml ", Encoding.UTF8);
|
change to:
code is as follows |
copy code |
return Content (str," Text/xml ", New UTF8Encoding (true));
|
is still missing BOM garbled, and the last modification is resolved as follows:
code is as follows |
copy code |
respon Se. Write (Encoding.UTF8.GetString (new byte[] {0xEF, 0xBB, 0xBF}));
Return Content (str, "Text/xml", Encoding.UTF8);
|
The above test uses Fusioncharts free-ver 2.2.