PDA

View Full Version : form submit response failes to parse in opera but in FF2 working



digitalkaoz
14 Jun 2007, 1:31 AM
he there, im having a problem in opera...
here is the ouput...

JavaScript - http://localhost:8080/jame/
Timeout thread: delay 50 ms
Error:

name: SyntaxError

message: Statement on line 35: Syntax error in call to eval: line 1 :

(<response type='success'

---^
Backtrace:
Line 35 of linked script http://localhost:8080/jame/js/extjs/ext-all.js

return eval("(" + _18 + ")");
Line 203 of linked script http://localhost:8080/jame/js/extjs/ext-all.js

if (this.form.errorReader)
return Ext.decode(_13.responseText);
Line 203 of linked script http://localhost:8080/jame/js/extjs/ext-all.js

this.response = _7;
if (! _7.responseText)
this.result = this.handleResponse(_7);
return this.result;
Line 203 of linked script http://localhost:8080/jame/js/extjs/ext-all.js

var _12 = this.processResponse(_11);
if (_12 === true || _12.success)
if (_12.errors)
this.form.afterAction(this, false);
Line 15 of linked script http://localhost:8080/jame/js/extjs/adapter/yui/yui-utilities.js

if (! _14)
var _16, _17;
if (o.conn.status !== undefined && o.conn.status != 0)
else
_16 = 13030;
if (_16 >= 200 && _16 < 300)
else
this.releaseObject(o);
_17 = null;
Line 15 of linked script http://localhost:8080/jame/js/extjs/adapter/yui/yui-utilities.js

if (o.conn && o.conn.readyState == 4)
At unknown location

[statement source code not available]


the response was

<response type="success">
<methodCall>User.login</methodCall>
<methodResponse>
<you>
<name>aname</name>
<server>aserver</server>
<port>aport</port>
</you>
</methodResponse>
</response>


where is the problem?
in FF2 i got no probs with this, maybe my ext-version is to old? i am using ext.1.0.1a

tryanDLS
14 Jun 2007, 7:21 AM
Use ext-all-debug.js so you can step thru the code. Did you set the right content-type for your response (multiple threads re this)?

digitalkaoz
14 Jun 2007, 10:29 AM
the contenttype is text/xml...

its in Ext.util.JSON the function is


this.decode = function(json){

return eval("(" + json + ')');

};
whats the problem in parsing an xml response? every post request to the server fails in opera
get-requests are working fine

please somebody gimme a hint :)

tryanDLS
14 Jun 2007, 11:28 AM
If you're reading XML, why is it going thru the JSON eval process? Or are you calling that function manually. Xml is returned as an Xml document, not a string.

digitalkaoz
15 Jun 2007, 5:57 AM
i think its a string, which is a valid xml, i cannot access the document directly, i have to parse it before...

the livecycle:

filling the form -> submitting -> generating xml-struct on server-side -> return the xml struct -> parsing the string? so it becomes an xml doc

here is the function to parse the xml, maybe theres the error


Jame.helpers.xml.loadXML = function(_xmldata){
// code for IE
if (window.ActiveXObject){
var doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async="false";
doc.loadXML(_xmldata);
}
// code for Mozilla, Firefox, Opera, etc.
else{
var parser=new DOMParser();
var doc=parser.parseFromString(_xmldata,"text/xml");
}
return doc.documentElement;
}

and the callback function, for "form submit success"


Jame.connection.login = function(f,a){
e = Jame.helpers.xml.loadXML(a.result);
//e = a.result
if(e.getAttribute("type") == "success"){
}else{
}
}

if the code is wrong, firefox would also return an error! but it doesnt... please help me, maybe my concept is wrong, what can i do so its working properly?

tryanDLS
15 Jun 2007, 7:53 AM
If you're building XML on the server, return an XML document, not a string. There's no pointing wasting the cycles on the client to parse the string into an Xml Dom if you don't have to.

digitalkaoz
16 Jun 2007, 10:16 AM
ok got it, it was all the time xml response from the server, dont know why im parsing it again ;) now i use

a.response.responseXML.firstChild

in FF its still working, but in opera it still fails (with the same error) , there must be something else where. and i cant figure out what or where :(

do you got another tip for me? :D sorry for bugging you

here is the function i added to my form "submit button"

LoginSubmit : function(){
this.LoginForm.submit({
waitMsg:'Please Wait...Connecting...',
reset:false,
success:Jame.connection.login, //callback method if Form.submit was successful
scope:this
});
}


even if my callback function Jame.connection.login is empty opera throws this error :(