[导入]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
- 比如下列的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