客户端

#!/usr/bin/env python
import tornado.ioloop
import tornado.web class MainHandler(tornado.web.RequestHandler):
def get(self, *args, **kwargs):
self.render('index.html')
def post(self, *args, **kwargs):
self.render('index.html') settings ={
'template_path':'views',#html文件模板路径配置
'static_path':'statics',#css,js文件路径配置
'static_url_prefix':'/sss/',
}
application = tornado.web.Application([
(r"/index", MainHandler), ],**settings)
if __name__ == "__main__":
application.listen(8000)
tornado.ioloop.IOLoop.instance().start()

app.py

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body> <input type="button" value="Jsonp" onclick="DoJsonpAjax();">
<script src="{{static_url('jquery-3.1.1.js')}}"></script>
<script>
function xxoo(arg){
console.log(arg)
}
function DoJsonpAjax() {
// var tag = document.createElement('script');
// tag.src = "http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list";
// document.head.appendChild(tag);
//
// document.head.removeChild(tag);
////
$.ajax({
url: "http://tao.com:8001/index",
dataType: 'jsonp',
jsonp:'callback',//相当于在url: "http://tao.com:8001/index?callback= xxoo",
jsonpCallback: "xxoo"//相当于在url: "http://tao.com:8001/index?callback= xxoo",
})
}
</script>
</body>
</html>

index.html

服务端

#!/usr/bin/env python
import tornado.ioloop
import tornado.web class MainHandler(tornado.web.RequestHandler):
def get(self, *args, **kwargs):
callback = self.get_argument('callback')
self.write("{}([11,22,33])".format(callback))
def post(self, *args, **kwargs):
self.write('t2.post') settings ={
'template_path':'views',#html文件模板路径配置
'static_path':'statics',#css,js文件路径配置
'static_url_prefix':'/sss/',
}
application = tornado.web.Application([
(r"/index", MainHandler), ],**settings)
if __name__ == "__main__":
application.listen(8001)
tornado.ioloop.IOLoop.instance().start()

app.py

最新文章

  1. MySQL 5.6 OOM 问题解决分享【转】
  2. java反射机制初探
  3. python : HTML+CSS (定时器轮寻)
  4. C++多线程开发之actor model
  5. Oracle多个服务各代表什么作用(转)
  6. Unreal Engine4 蓝图讲解
  7. UITextFiled自动补全输入,选中补全内容。NSRange和UITextRange的相互转换。-b
  8. jQuery validate api(转)
  9. Oracle索引语句整理
  10. synchronized和lock比较浅析
  11. C#在属性中用Lambda语法
  12. 十、Hadoop学习笔记————Hive与Hbase以及RDBMS(关系型数据库)的关系
  13. appium-android 遇到swipe函数无法使用的问题及解决办法
  14. netty源码解解析(4.0)-14 Channel NIO实现:读取数据
  15. Dubbo接口压测
  16. Python 闭包(Closure)
  17. Brute Force Sorting(HDU6215)
  18. AR2220 通过cpu-defend policy处理大量大量arp广播的小技巧
  19. SQL select语句执行顺序
  20. 程序设计分层思想和DAO设计模式的开发

热门文章

  1. cpu和gpu的区别和联系是什么
  2. spring boot: 线程池ThreadPoolTaskExecutor, 多线程
  3. 直方图均衡化的 C++ 实现(基于 openCV)
  4. 我总结的call()与apply()方法的区别
  5. 《Advanced Bash-scripting Guide》学习(十五):测试坏的链接文件(broken link)
  6. hzau 1209 Deadline(贪心)
  7. MySQL 分区知识点(三)
  8. xdebug的安装测试
  9. Codeforces Round #242 (Div. 2)C(找规律,异或运算)
  10. 5.MySQL优化---索引优化专题