<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.11.0.js" ></script>
<script type="text/javascript">
$.ajax({
type:"get",
url:"http://192.168.32.68/jsonp/",
dataType: 'jsonp',
jsonp: "callback",
jsonpCallback: "hello",
success: function(data) {
alert(data);
},
error: function(err) {
alert(err);
}
});
</script>
</head>
<body>
</body>
</html>
def jsonp(request):
callback = request.GET.get('callback');
res = callback+'({"code": "CA1998","price": 1780,"tickets": 5})'
return HttpResponse(res);
参考文章:http://www.cnblogs.com/dowinning/archive/2012/04/19/json-jsonp-jquery.html
视频教程:http://www.jikexueyuan.com/course/787_3.html?ss=1