AW: [Dojo-interest] Re: How to read the response from dojo bind

Martin Kluger martin.kluger at tradespark.eu
Tue Jan 2 12:41:05 MST 2007


Hello Troy,

if you look in dojo/src/BrowserIO.js in the dojo.io.XMLHTTPTransport.doLoad
method you will see the following snippet (current repository):

---snip---
else if(kwArgs.mimetype == "text/json" || kwArgs.mimetype ==
"application/json"){
				try{
					ret =
dj_eval("("+http.responseText+")");
				}catch(e){
					dojo.debug(e);
					dojo.debug(http.responseText);
					ret = false;
				}
			}else if (
[...]
			}else{
				ret = http.responseText;
			}
---snip---

Returned HTML cannot be converted to a valid js object so the result will
always be false and the server response is lost. Either you extend/modify
the catch statement to return the response anyway (bad idea because you have
to parse in *every* request) or use a text/plain mimetype to
'eval/catch/parse html' yourself if *really* needed (as mentioned by
dustin).

Do you want to stick with the json mimetype even if you want to parse the
returned html anyway?

Regards
Martin


> -----Ursprüngliche Nachricht-----
> Von: dojo-interest-bounces at dojotoolkit.org [mailto:dojo-interest-
> bounces at dojotoolkit.org] Im Auftrag von troyf
> Gesendet: Dienstag, 2. Januar 2007 20:09
> An: dojo-interest at dojotoolkit.org
> Betreff: [Dojo-interest] Re: How to read the response from dojo bind
> 
> Diego, Dustin,
> 
> Thanks for the quick replies.
> 
> Diego, yes that was what I was hoping I could do but data just resolves
> false, while in the response tab of Firebug I can see the entire contents
> of
> the html returned from the server.
> 
> Dustin, I think I need to keep the mimetype at text/json since I post json
> to the server and I am expecting (server errors aside) json to be
> returned.
> 
> Do either of you have more ideas?
> 
> thanks,
> 
> T



More information about the Dojo-interest mailing list