On 19 nov, 22:52, Myk Melez <
m...@mozilla.org> wrote:
>
> That's strange, as 302 is a redirect code, which XHR should follow
> transparently. In other words, XHR shouldn't hand you a 302 response, it
> should follow the redirect and then hand you the response to its request
> for the resource to which it was redirected.
That's what i thought about 302 and it was what i expected, in fact
firebug shows in Network XHR console the html fragment i requested.
> Perhaps the server issued a 302 response without a Location response
> header? In that case, it seems reasonable for XHR to call your error
> handler, because the server told the client to look elsewhere for the
> resource but didn't tell it where to look.
I've tampered the request and response headers with Tamper Data
extension, and the Location header is present, in fact, when debuggin'
the jetpack i can see the result of the XHR, as i've said, as proof of
successful redirection, at least to the browser XHR object.
On the other hand, taking a look to jQuery code from
\
jet...@labs.mozilla.com\content\js\ext directory, i've found that
XHR.status = error (textStatus="error" in jQuery terms, what i obtain)
is got when jQuery.httpSuccess( xhr ) is false, and it's false when
status code is 302 i.e.
Changing the boolean expression to admit 302 as a valid code doesn't
make anything better, it just return the "raw" xml response as valid
data, not the html response in firebug fields terms(Params, headers,
response and html in Network->XHR).
As example:
1. The response as firebug give us is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://
www.w3.org/1999/xhtml" xml:lang="es" lang="es"><head><meta http-
equiv="Content-Type" content="text/html; charset=utf-8" /><meta
name="google" value="notranslate"><title>TrickyDomain-Ajax</
title><script type="text/javascript">document.domain =
location.host.match(/trickyDomain\.com$/) ? 'trickyDomain.com' :
'trickyDomain.local';</script></head><body><xmp id="request_data"
success="1" return_code="200" updates="{"new_messages":0}"
title="Inicio" ></xmp><xmp id="canvas"><div id="home"
class="layout-0"><div class="sidebar left"><div id="main_info"
class="mod n"><div class="body"><h2> <a
href="#m=Profile&func=index" onclick="...
2. The html as firebug give us is
<div id="home" class="layout-0"><div class="sidebar left"><div
id="main_info" class="mod n"><div class="body"><h2> <a
href="#m=Profile&func=index" onclick="...
3. The data when successful (remember i've manipulated jQuery code)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://
www.w3.org/1999/xhtml" xml:lang="es" lang="es"><head><meta http-
equiv="Content-Type" content="text/html; charset=utf-8" /><meta
name="google" value="notranslate"><title>TrickyDomain-Ajax</
title><script type="text/javascript">document.domain =
location.host.match(/trickyDomain\.com$/) ? 'trickyDomain.com' :
'trickyDomain.local';</script></head><body><xmp id="request_data"
success="1" return_code="200" updates="{"new_messages":0}"
title="Inicio" ></xmp><xmp id="canvas"><div id="home"
class="layout-0"><div class="sidebar left"><div id="main_info"
class="mod n"><div class="body"><h2> <a
href="#m=Profile&func=index" onclick="...
this data should be like data in point nº 2.
Of course with the original jQuery code i get an error and in this
case XHR.responseText is equal to nº1 or nº3.
Hope i've been clear enough (but i don't think so...sorry if not).
Thanks again.