状态200的响应:确定

编程入门 行业动态 更新时间:2024-10-07 08:30:49
本文介绍了状态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/package/angular2-highcharts '首先了解如何绘制.JSON数据并且它能够工作。我将这些数据用于该示例,并创建了一个本地.JSON文件(从 www.highcharts/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 'www.npmjs/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 'www.highcharts/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('www.highcharts/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帮助。在这个答案中的建议 stackoverflow/a/36305814/4567096 。

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

更多推荐

状态200的响应:确定

本文发布于:2023-10-10 18:22:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479366.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!