您的位置:首页 > Web前端 > JQuery

框架----Django之Ajax全套实例(原生AJAX,jQuery Ajax,“伪”AJAX,JSONP,CORS)

2017-07-06 17:41 579 查看

一、原生AJAX,jQuery Ajax,“伪”AJAX,JSONP

1. 浏览器访问

http://127.0.0.1:8000/index/

http://127.0.0.1:8000/fake_ajax/

http://127.0.0.1:8000/index/jsonp/

http://127.0.0.1:8000/autohome/

2. urls

from django.shortcuts import render,HttpResponse

# Create your views here.

import json
def user(request):
print(request.method)
if request.method == "OPTIONS":

obj = HttpResponse()
obj["Access-Control-Allow-Origin"] = "*"
obj["Access-Control-Allow-Methods"] = "DELETE"
return obj

obj = HttpResponse("..")
obj["Access-Control-Allow-Origin"] = "*"
return obj

view.py
views.py

 

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