From: Alan Knowles Date: Thu, 27 Dec 2018 07:28:38 +0000 (+0800) Subject: Roo/data/Connection.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=4ea864e6e7095bdca44eec552f71c7becea00239 Roo/data/Connection.js --- diff --git a/Roo/data/Connection.js b/Roo/data/Connection.js index 8485d1f9f3..665805f0d2 100644 --- a/Roo/data/Connection.js +++ b/Roo/data/Connection.js @@ -338,89 +338,35 @@ Roo.extend(Roo.data.Connection, Roo.util.Observable, { doFormUploadNew : function(o, ps, url){ - var id = Roo.id(); - var frame = document.createElement('iframe'); - frame.id = id; - frame.name = id; - frame.className = 'x-hidden'; - if(Roo.isIE){ - frame.src = Roo.SSL_SECURE_URL; - } - document.body.appendChild(frame); - - if(Roo.isIE){ - document.frames[id].name = id; - } - - var form = Roo.getDom(o.form); - form.target = id; - form.method = 'POST'; - form.enctype = form.encoding = 'multipart/form-data'; - if(url){ - form.action = url; - } - - var hiddens, hd; - if(ps){ // add dynamic params - hiddens = []; - ps = Roo.urlDecode(ps, false); - for(var k in ps){ - if(ps.hasOwnProperty(k)){ - hd = document.createElement('input'); - hd.type = 'hidden'; - hd.name = k; - hd.value = ps[k]; - form.appendChild(hd); - hiddens.push(hd); - } - } - } - - function cb(){ - var r = { // bogus response object - responseText : '', - responseXML : null - }; - - r.argument = o ? o.argument : null; - - try { // - var doc; - if(Roo.isIE){ - doc = frame.contentWindow.document; - }else { - doc = (frame.contentDocument || window.frames[id].document); - } - if(doc && doc.body){ - r.responseText = doc.body.innerHTML; - } - if(doc && doc.XMLDocument){ - r.responseXML = doc.XMLDocument; - }else { - r.responseXML = doc; - } - } - catch(e) { - // ignore + + var formData = new FormData(Roo.getDom(o.form)); + + + var cb = { + success: this.handleResponse, + failure: this.handleFailure, + scope: this, + argument: {options: o}, + timeout : o.timeout || this.timeout + }; + + var method = "POST"; + + + + if(typeof o.autoAbort == 'boolean'){ // options gets top priority + if(o.autoAbort){ + this.abort(); } - - Roo.EventManager.removeListener(frame, 'load', cb, this); - - this.fireEvent("requestcomplete", this, r, o); - Roo.callback(o.success, o.scope, [r, o]); - Roo.callback(o.callback, o.scope, [o, true, r]); - - setTimeout(function(){document.body.removeChild(frame);}, 100); + }else if(this.autoAbort !== false){ + this.abort(); } - Roo.EventManager.on(frame, 'load', cb, this); - form.submit(); - - if(hiddens){ // remove dynamic params - for(var i = 0, len = hiddens.length; i < len; i++){ - form.removeChild(hiddens[i]); - } - } + + this.transId = Roo.lib.Ajax.request(method, url, cb, formData, o); + + + } });