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);