深究的东西 - AJAX高效开发

Get / Post 请求

Post发送数据分2次,一次header,一次body,所以post会快一些

XMLHttpRequest.getAllResponseHeaders()

XMLHttpRequest.responseText

XMLHttpRequest.setRequestHeader

XMLHttpRequest.open()

XMLHttpRequest.send

跨域请求: 动态脚步插入

Multipart XHR: 切分处理

  http://techfoolery.com/mxhr/

  imageString.split('\u0001'),  

  if(req.readyState===3){

    window.setInterval(fn, 15)

    // req.responseText.substring(lastlength, length)

  }

最轻量级请求“信号灯”

var params=["step=2", 'page=3']

new Image().src=url+'?'+params.join('&')

image.onload=function(){

  if(this.width==1){success}

  if(this.width==2){failure, try again}

}

数据格式: 性能比较、优缺点

  Verbose XML, Verbose JSON, Simple JSON, Array  JSON, Custom Format(Script Insertion)

  Simple XML, Verbose JSON-P, Simple JSON-P, Array JSON-P, Custom Format(XHR)

数据缓存: Cookie, Last Modified Date, Expire, Request Header, Server side configuration

 

Long Poll:

  iframe, comet, 

posted @ 2015-05-06 00:31  Derek_Hu  阅读(134)  评论(0编辑  收藏  举报