推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
ray1888
V2EX  ›  Python

Django 跨域问题

  •  
  •   ray1888 ·
    ray1888 · Jun 23, 2017 · 2277 views
    This topic created in 3380 days ago, the information mentioned may be changed or developed.

    我现在用 Django 写了一个测试的网页用于测试如果不用模板如何进行前后端信息交互,正常访问成功返回一个 json 数据,在页面中用 jquery 发出请求,出现了浏览器跨域问题,应该如何解决。

    <script> $.get('http://127.0.0.1:8000/index/index',function(data){ alert('data='+data); }); </script>

    浏览器报错 XMLHttpRequest cannot load http://127.0.0.1:8000/index/index. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

    2 replies  •  2017-06-23 13:43:17 +08:00
    KgM4gLtF0shViDH3
        1
    KgM4gLtF0shViDH3  
       Jun 23, 2017 via Android
    用装饰器
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2728 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 03:15 · PVG 11:15 · LAX 20:15 · JFK 23:15
    ♥ Do have faith in what you're doing.