您的位置:首页 > 编程语言 > Go语言

DJANGO的API跨域实现

2016-08-11 15:26 197 查看
Ajax跨域请求报错:XMLHttpRequest cannot load ''. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' ' is therefore not allowed access.

这种错误如何解决?

一种是JSONP。

一种是DJANGO上的第三方插件:django-cors

相当URL:
http://stackoverflow.com/questions/38649170/django-cors-x-firephp-version https://github.com/ottoyiu/django-cors-headers
基本设置:

django-cors-headers

A Django App that adds CORS (Cross-Origin Resource Sharing) headers to responses.

Although JSON-P is useful, it is strictly limited to GET requests. CORS builds on top of XmlHttpRequest to allow developers to make cross-domain requests, similar to same-domain requests. Read more about it here:http://www.html5rocks.com/en/tutorials/cors/



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: