希望能够通过对瑞典统计局(SCB)的ajax调用来帮助识别问题。
SCB API instructions are hereAjax调用json数据的问题来自瑞典统计公共API
我能顺利拿到下面呼叫
$.ajax({
url: "http://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0401/BE0401B",
type: "POST",
dataType: 'json',
success: function(response) {
console.log(response);
},
error: function(xhr) {
console.log(xhr.statusText)
}
});
不过,我收到404未找到错误,当我尝试以下查询表用POST表的元数据(步骤4.3说明)请求。
(例如从步骤4.4说明服用 - PDF 7页的下半部)
或者,如果我试图用GET请求,我只是得到取得该表的元数据和没有结果
$.ajax({
url: "http://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0401/BE0401B/BefProgFoddaMedel15",
data: {
"query":
[{"code":"Fodelseland", "selection":{"filter":"item",
"values":["010","020"]}},
{"code":"Alder", "selection":{"filter":"all", "values":["*"]}},
{"code":"Tid", "selection":{ "filter":"top", "values":["3"]}}],
"response": {"format":"json"}
},
type: "POST", // GET returns only table metadata
dataType: 'json',
success: function(response) {
console.log(response);
},
error: function(xhr) {
console.log(xhr.statusText)
}
});
编辑
补充说,还试图用GET请求,但只返回表的元数据,而不是统计
解答
在发布前调用JSON.stringify查询数据。
由Petros Likidis发布的代码
你的数据格式是错误的尝试适合作为在4.3 PDF –
定步骤@MudassarZahid你能否以正确的ajax调用为例来扩展你的答案?你的回答很不清楚。 – seablue