X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/b37ceabb82336ee82757cd32efe353cfab8ec267..f5240829880f87e0cf581c6a296e436fdef0ef80:/src/ext-core/src/adapter/ext-base-ajax.js diff --git a/src/ext-core/src/adapter/ext-base-ajax.js b/src/ext-core/src/adapter/ext-base-ajax.js index 1067b4e3..57c56b7f 100644 --- a/src/ext-core/src/adapter/ext-base-ajax.js +++ b/src/ext-core/src/adapter/ext-base-ajax.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.2.2 + * Ext JS Library 3.3.0 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license @@ -11,15 +11,16 @@ * http://developer.yahoo.net/yui/license.txt */ Ext.lib.Ajax = function() { - var activeX = ['MSXML2.XMLHTTP.3.0', - 'MSXML2.XMLHTTP', - 'Microsoft.XMLHTTP'], + var activeX = ['Msxml2.XMLHTTP.6.0', + 'Msxml2.XMLHTTP.3.0', + 'Msxml2.XMLHTTP'], CONTENTTYPE = 'Content-Type'; // private function setHeader(o) { var conn = o.conn, - prop; + prop, + headers = {}; function setTheHeaders(conn, headers){ for (prop in headers) { @@ -29,14 +30,9 @@ Ext.lib.Ajax = function() { } } - if (pub.defaultHeaders) { - setTheHeaders(conn, pub.defaultHeaders); - } - - if (pub.headers) { - setTheHeaders(conn, pub.headers); - delete pub.headers; - } + Ext.apply(headers, pub.headers, pub.defaultHeaders); + setTheHeaders(conn, headers); + delete pub.headers; } // private @@ -168,10 +164,28 @@ Ext.lib.Ajax = function() { releaseObject(o); responseObject = null; } + + function checkResponse(o, callback, conn, tId, poll, cbTimeout){ + if (conn && conn.readyState == 4) { + clearInterval(poll[tId]); + poll[tId] = null; + + if (cbTimeout) { + clearTimeout(pub.timeout[tId]); + pub.timeout[tId] = null; + } + handleTransactionResponse(o, callback); + } + } + + function checkTimeout(o, callback){ + pub.abort(o, callback, true); + } + // private function handleReadyState(o, callback){ - callback = callback || {}; + callback = callback || {}; var conn = o.conn, tId = o.tId, poll = pub.poll, @@ -179,26 +193,9 @@ Ext.lib.Ajax = function() { if (cbTimeout) { pub.conn[tId] = conn; - pub.timeout[tId] = setTimeout(function() { - pub.abort(o, callback, true); - }, cbTimeout); + pub.timeout[tId] = setTimeout(checkTimeout.createCallback(o, callback), cbTimeout); } - - poll[tId] = setInterval( - function() { - if (conn && conn.readyState == 4) { - clearInterval(poll[tId]); - poll[tId] = null; - - if (cbTimeout) { - clearTimeout(pub.timeout[tId]); - pub.timeout[tId] = null; - } - - handleTransactionResponse(o, callback); - } - }, - pub.pollInterval); + poll[tId] = setInterval(checkResponse.createCallback(o, callback, conn, tId, poll, cbTimeout), pub.pollInterval); } // private @@ -280,30 +277,31 @@ Ext.lib.Ajax = function() { }, serializeForm : function(form) { - var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements, - hasSubmit = false, - encoder = encodeURIComponent, - name, - data = '', - type; - - Ext.each(fElements, function(element) { + var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements, + hasSubmit = false, + encoder = encodeURIComponent, + name, + data = '', + type, + hasValue; + + Ext.each(fElements, function(element){ name = element.name; type = element.type; - - if (!element.disabled && name){ - if(/select-(one|multiple)/i.test(type)) { - Ext.each(element.options, function(opt) { + + if (!element.disabled && name) { + if (/select-(one|multiple)/i.test(type)) { + Ext.each(element.options, function(opt){ if (opt.selected) { - data += String.format("{0}={1}&", encoder(name), encoder((opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttribute('value') !== null) ? opt.value : opt.text)); + hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified; + data += String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text)); } }); - } else if(!(/file|undefined|reset|button/i.test(type))) { - if(!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)){ - - data += encoder(name) + '=' + encoder(element.value) + '&'; - hasSubmit = /submit/i.test(type); - } + } else if (!(/file|undefined|reset|button/i.test(type))) { + if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) { + data += encoder(name) + '=' + encoder(element.value) + '&'; + hasSubmit = /submit/i.test(type); + } } } });