[导入]AJAX good practices

Reuse code and encapsulate frozen code

- 比如下列的code就可以分离出来

function buildRequest(target,method,params,handler,isAsync) {
var req = window.XmlHTTPRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
if(req) {
req.open(method, target, isAsync); req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
req.setRequestHeader("Content-length",params.length);

文章来源:http://www.gins.cn/blog/article.asp?id=56

posted on 2006-09-05 15:45  ginseng  阅读(108)  评论(0编辑  收藏  举报

导航