原生JS

jquery太有名了,以至于大家都忘记原生的js了。

jquery一般有两个用处:浏览器兼容,简化dom操作。现在浏览器更新都很快,除了IE6用的人已经很少了。

例子1,发消息

win7的IE是IE11,2013年的。
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET","http://127.0.0.1:5000/hello/",true);
xmlhttp.send(null);
    
    function state_Change(){
      if (xmlhttp.readyState==4)
         console.log('99999999999', xmlhttp.status, xmlhttp.responseText);
    }
    flask支持跨域也很方便,return时,加上code和http头就可以了
    @app.route('/hello/')
    @app.route('/hello/<name>')
    def hello(name=None):
     return render_template('hello.html', name=name),200,{"Access-Control-Allow-Origin":"*"}
    
    dom操作,见 http://blog.csdn.net/DUDUfine/article/details/75944536

同步发消息更简单

xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","http://127.0.0.1:5000/hello/",false);
xmlhttp.send(null);

console.log('99', xmlhttp.status, xmlhttp.responseText);
   

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值