本文介绍了HTTP POST请求AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我实际上在使用SparQL查看器,但我的POST请求有问题,有人可以告诉我出了什么问题?
I'm actually working on a SparQL viewer but i got an issue with my POST request, someone can told me what's wrong ?
var req = { method: 'POST',
url: 'http://dbpedia.org/sparql',
headers: { 'Content-type' : 'application/x-www-form-urlencoded',
'Accept' : 'application/sparql-results+json' },
data: { query : "SELECT * WHERE { <http://dbpedia.org/resource/Awolnation> ?pref ?obj } LIMIT 10",
format: "sparql-results+json",
timeout : 3000 }
};
$http(req).success(function(data) {
console.log(data);
});
编辑:我的错,我忘了这个问题
EDIT : my bad i forgot the issue
POST http://dbpedia.org/sparql 400 (Bad Request)
推荐答案
我认为这是一个GET查询, format = json
喜欢:
I think it's a GET query and format=json
like :
var req = {
method: 'GET',
url: 'http://dbpedia.org/sparql',
headers: { 'Content-type' : 'application/x-www-form-urlencoded',
'Accept' : 'application/sparql-results+json' },
params: {
query : "SELECT * WHERE { <http://dbpedia.org/resource/Awolnation> ?pref ?obj } LIMIT 10",
format: "json"
}
};
当Dbpedia端点未关闭时,它可以工作:)。
It's work when Dbpedia endpoint is not down :).
这篇关于HTTP POST请求AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!