使用REST输出到网页
问题描述:
我对此非常陌生,并以启动引导模板开始。使用REST输出到网页
,我得到了这样的代码的网页上
<div class="panel-body">
<div id="morris-area-chart"></div>
</div>
这是由名为习俗,data.js与像内容的js文件备份:
$(function() {
Morris.Area({
element: 'morris-area-chart',
data: [{
period: '2010 Q1',
iphone: 2666,
ipad: null,
itouch: 2647
}, {
period: '2010 Q4',
iphone: 3767,
ipad: 3597,
itouch: 5689
}, {
period: '2011 Q4',
iphone: 15073,
ipad: 5967,
itouch: 5175
}, {
period: '2012 Q2',
iphone: 8432,
ipad: 5713,
itouch: 1791
}],
xkey: 'period',
ykeys: ['iphone', 'ipad', 'itouch'],
labels: ['iPhone', 'iPad', 'iPod Touch'],
pointSize: 2,
hideHover: 'auto',
resize: true
});
});
我休息服务http://myserver/rest/charts
它以json格式返回响应 。
我被卡住的第一个计时器的问题是如何用我的REST服务的输出替换样本日期。
任何工作代码或指针会大大帮助。
答
我用类似下面
fdata=$.ajax({ url: 'http://myrestserver/rest/v1/feedbackerrors?onlyData=true',
type: 'get',
dataType: 'json',
success: function(output) {
console.log(output) ;
}
});
当你邮寄或到您的REST服务。尝试编写调试器来获得成功。像这样: 'success:function(data){debugger; }' 现在在控制台打开的情况下运行你的代码,你就可以写数据,看看你从服务中得到了什么。 –
你能提供一个来自REST服务的json响应的例子吗? – Haring10