每天一个随笔

今天又重新回顾了一下,源生JS写Ajax请求。

var xmlhttp;
if(window.XMLHttpRequest){
  xmlhttp = new XMLHttpRequst();
}else{
  xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}

xmlhttp.open('GET',url,true);
xmlhttp.send(null);

xmlhttp.onreadystatechange = function(){
  if(xmlhttp.readyState==4&&xmlhttp.status==200){
    var data= xmlhttp.responseText;  //对字符串进行解析
    //var data = xmlhttp.responseXml; 对xml文件进行解析
  }  
}

学习到了分页缓存的使用,因为每次分页显示都要去数据库查询的话,无疑会增加增加服务器和数据库的负担,数据库查询依然会有一定反应时间。而分页缓存是将自己浏览过的分页数据存储到一个自定义的cache数组中。如果已经浏览过这个pageNo(第N页),那么便会从cache中取出数据。避免再次去查询数据库。

最后学习了Vue.js的使用,写了几个demo。

posted @ 2017-06-18 00:59  MesopotamiazZ  阅读(109)  评论(0编辑  收藏  举报