PDA

View Full Version : submit returns no response



jaforom
29 Sep 2009, 12:36 AM
Hi all,

when I make a submit(), the response came back empty in the action parameter of success event, with no result property. In firedebug I see the response in JSON format. Any idea? Thanks

jaforom
29 Sep 2009, 5:51 AM
The code of FormPanel is


var kmlForm = new Ext.FormPanel({
fileUpload: true,
frame: false,
bodyStyle: 'padding:10px 10px 10px 10px;',
autoHeight:true,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [{
xtype: 'fileuploadfield',
id: 'kmlFile',
name: 'kmlFile',
fieldLabel:'',
buttonText: 'Examinar',
hideLabel:true
},{
xtype: 'hidden',
id: 'domain',
name: 'domain',
value: documentDomain
}],
buttons: [{
text: 'Cargar',
handler: function(){
var fp = this.ownerCt.ownerCt;
if (fp.getForm().isValid()) {
fp.getForm().submit({url:grafcan.urlLoadKML,method:'POST',
success:function(form, action){
alert('submit ok')},
failure:function(form, action){
alert('submit failed')}/*,waitTitle:'Espere, por favor',waitMsg:'Cargando KML...'*/});
}
}
}]
});The response is the same: empty responseText of action.response. There's no action.result property.

In firebug I see that the response is like


{"success":true,"data":{"id":1,"url":"http:\/\/...\/KML\/8458_l0gg1qjiva80to529ifd7tvq42.kml","error":""}}

jaforom
30 Sep 2009, 5:12 AM
I found the reason: there was an error (famous "Denied access" error) in the callback function (ext-all.js), when the following line was executed:



doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;

I return the HTML with a javascript statement that modifies document's domain property.


function cb(){
var me = this,
// bogus response object
r = {responseText : '',
responseXML : null,
argument : o.argument},
doc,
firstChild;

try{
doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;>:)
if(doc){
if(doc.body){
if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea
r.responseText = firstChild.value;
}else{
r.responseText = doc.body.innerHTML;
}
}
//in IE the document may still have a body even if returns XML.
r.responseXML = doc.XMLDocument || doc;
}
}
catch(e) {}

Ext.EventManager.removeListener(frame, LOAD, cb, me);

me.fireEvent(REQUESTCOMPLETE, me, r, o);

function runCallback(fn, scope, args){
if(Ext.isFunction(fn)){
fn.apply(scope, args);
}
}