【发布时间】:2017-08-14 20:41:37
【问题描述】:
我正在尝试使用 AngularJS 向 Bottle 发出跨域 JSONP 请求,但出现错误。
角度:
// this angular code is on localhost:8888, so it's cross domain
var URL = "http://localhost:8000/test";
URL = $sce.trustAsResourceUrl(URL);
$http.jsonp(URL, {jsonpCallbackParam: 'callback'})
.then(function successCallback(response) {
console.log(response);
}, function errorCallback(error) {
console.log(error);
});
瓶子:
@route('/test')
def test():
response.headers['Content-Type'] = 'application/json'
return json.dumps({"random": "JSON"})
【问题讨论】:
标签: python angularjs ajax jsonp bottle