状态200的响应:确定 [英] response with status 200: ok

查看:142
本文介绍了状态200的响应:确定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何使用angular2-highcharts示例从本地'.JSON'文件绘制数据。

I am trying to figure out how to plot data from a local '.JSON' file using angular2-highcharts example.

我按照 https: //www.npmjs.com/package/angular2-highcharts '首先了解如何绘制.JSON数据并且它能够工作。我将这些数据用于该示例,并创建了一个本地.JSON文件(从 https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK 'in notepad and saved它使用UTF-8编码作为.JSON文件),并将JSON请求的文件路径替换为此。当我这样做时,我得到了状态为200的错误响应。

I followed the example in 'https://www.npmjs.com/package/angular2-highcharts' to first understand how to plot .JSON data and it worked. I took the data available for the example and created a local .JSON file (copied the content from 'https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK' in notepad and saved it with UTF-8 encoding as a .JSON file), and replaced the file path for the JSON request to this. When I do this though, I get an error - response with status 200.

  constructor(jsonp : Jsonp) {
    //jsonp.get('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=JSONP_CALLBACK').subscribe(res => {
        jsonp.get('./data.json').subscribe(res => {
        this.options = {
            title : { text : 'AAPL Stock Price' },
           series : [{
               name : 'AAPL',
               data : res.json(),
              tooltip: {
                   valueDecimals: 2
              }
         }]
        };
    });
}
options: Object;
};

因为我对json data / Javascript或angular2不是很熟悉,所以我不确定是否缺少一些非常基本的东西。 b

Since I am not super familiar with json data/ Javascript or angular2 I am not sure if I am missing something very basic here. Any help is appreciated.

推荐答案

使用http代替json帮助。在这个答案中的建议 https://stackoverflow.com/a/36305814/4567096

Using http instead of json helped. I made use of the suggestion in this answer https://stackoverflow.com/a/36305814/4567096.

这篇关于状态200的响应:确定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆