Ten的XHR
来源:互联网 发布:淘宝中年女模特叫什么 编辑:程序博客网 时间:2024/06/05 12:01
Ten.XHR = new Ten.Class({ // XHR : XMLHttpRequest initialize: function(uri,opts,obj,callPropertyName) { // Ten.EventDispatcher.implementEventDispatcher(this); // this.method = 'GET'; // // if (!uri) return; // // if (!Ten.XHR.isSafeUri(uri)) { // throw "host differs : " + uri; // } // // if (!opts) opts = {}; // 只是为了opts.method不报错 // if (opts.method) // this.method = opts.method; // // var self = this; // this.addEventListener('complete', function() { // if (!obj) return; // if (typeof(obj) == 'function' && typeof(callPropertyName) == 'undefined') { // obj.call(obj, self.request); // } else { // obj[callPropertyName].call(obj, self.request); // } // }); // // this.load(uri, opts.data); // }, // getXMLHttpRequest: function() { // var xhr; // var tryThese = [ // function () { return new XMLHttpRequest(); }, // function () { return new ActiveXObject('Msxml2.XMLHTTP'); }, // function () { return new ActiveXObject('Microsoft.XMLHTTP'); }, // function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); } // ]; // for (var i = 0; i < tryThese.length; i++) { // var func = tryThese[i]; // try { // xhr = func; // return func(); // } catch (e) { // //alert(e); // } // } // return xhr; // }, // isSafeUri: function(uri) { // if (uri.match(/^\w+:/) || uri.match(/^\/\//)) { // if (uri.split('/')[2] == location.host) return true; // else return false; // } else if (uri.match(/^\/[^\/]/) || uri == '/') { // return true; // } else if (!uri || uri.length == 0) { // return false; // } // return true; // }, // makePostData: function(data) { // var regexp = /%20/g; // if (typeof data == 'string' || (data instanceof String)) { // return encodeURIComponent(data).replace(regexp, '+'); // } // var pairs = []; // for (var k in data) { // if (typeof data[k] == 'undefined') continue; // var prefix = encodeURIComponent(k).replace(regexp, '+') + '='; // var values = Array.prototype.concat(data[k]); // for (var i = 0; i < values.length; i++) { // var pair = prefix + encodeURIComponent(values[i]).replace(regexp, '+'); // pairs.push(pair); // } // } // return pairs.join('&'); // } //},{ // load: function(url, params) { // var req = Ten.XHR.getXMLHttpRequest(); // this.request = req; // // var self = this; // req.onreadystatechange = function() { // self.stateChangeHandler.call(self, req); // }; // params = params ? Ten.XHR.makePostData(params) : null; // // req.open(this.method, url, true); // if (this.method == 'POST') // req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // 最常见的 POST 提交数据的方式.提交的数据按照 key1=val1&key2=val2 的方式进行编码,key 和 val 都进行了 URL 转码。 req.send(params); // }, // stateChangeHandler: function(req) { // this.dispatchEvent('state_change'); // // if (req.readyState == 4) { // this.dispatchEvent('ready', req.status.toString()); // // if (req.status >= 200 && req.status < 300) { // this.dispatchEvent('complete', req); // } else { // this.dispatchEvent('error', req); // } // } // } //}); //
0 0
- Ten的XHR
- xhr的浏览器差异
- winjs.xhr的认识
- XHR的用法
- xhr的jQuery方法
- xhr
- XHR
- XHR
- ten
- ten
- 你不知道的XHR
- XHR的用法详细解读
- XHR对象的get请求
- 一个完整的xhr请求
- xhr的jQuery用法总结
- ajax的实现,基于XHR的原理
- AJAX (XHR)异步请求的一些认识
- XHR的常用属性 和 方法
- linux0.12内核—初始化程序
- mdb数据库文件如何导入到Microsoft SQL Server 2008中
- catalan数,两排,分别从低到高排序,第二排相应的比第一排高
- UFLDL教程—自编码线性解码器学习
- 复古式的立体CSS菜单实例
- Ten的XHR
- hdu3336 &&hdu 4552 KMP ,SAM
- 有一个整数数组,请求出两两之差绝对值最小的值,记住,只要得出最小值即可,不需要求出是哪两个数。
- Aspect
- 动态规划
- Medoo Select的使用:查询数据
- Hadoop源代码分析之Hadoop RPC(RPC和Client)
- 装饰模式
- AJAX file uploads in Rails using attachment_fu and responds_to_parent 1