#13388 closed bug (fixed)
Ajax request not returning responseXML
Reported by: | Nao | Owned by: | jaubourg |
---|---|---|---|
Priority: | high | Milestone: | 1.10 |
Component: | ajax | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hello.
Yesterday I found a bug in jQuery's behavior when doing a synchronous request to my server. (Yes, I know it's bad, but this is the only sync request in my entire, very large codebase, and can hardly be rewritten without adding too much unnecessary code, so I'd rather keep it this way.)
Whether you send a dataType (to xml) or not, it doesn't matter, having it set on auto or xml is the same. My server sends a proper string containing well-formed XML, and it is seen as text by jQuery, i.e. it returns a responseText but not responseXML object.
This bug can be reproduced in both jQuery 2.0 and jQuery 1.9.1, but not in jQuery 1.9.0.
I fixed it on my side by returning a text string without any tags (which had the added benefit of not wasting bandwidth and making my code shorter :)), but I'd rather not have this bug stay in the codebase, too afraid many sites will break and not understand why.
So I traced through the code, and I think the culprit is at line 8560 in jquery-git.js, or rather the missing lines of code that were in lines 8514 and 8516-8520 in jquery-1.9.0.js, which reference a bug fix for this unrelated report:
http://bugs.jquery.com/ticket/4958
The report above was reopened last year, but I don't know why the fix was removed.
Here's an old jsfiddle snippet I found that reproduces this. Select jQuery 1.9.0, it works. Select jQuery (Edge) (i.e. 1.9.1pre) or jQuery 2.0.0b1, it doesn't work (responseXML is undefined).
Hopefully this is enough information to help you guys fix this without too much hassle.
Change History (20)
comment:1 Changed 10 years ago by
Component: | unfiled → ajax |
---|---|
Milestone: | None → 1.9.2 |
Owner: | set to jaubourg |
Priority: | undecided → high |
Status: | new → assigned |
Version: | git → 1.9.1 |
comment:2 Changed 10 years ago by
Yup, as I said, it's a synchronous JAX bug only, not an AJAX bug :) Switching to asynchronous mode is the 'easy' fix, but it's not a permanent solution if you wish for jQuery to remain compatible with most existing scripts.
(It was already hard enough for me to figure out I had to update my .attr('checked') and similar to .prop(), as the 1.9 upgrade grade doesn't clearly state that it's become mandatory in this version, just like it was in v1.6.0...)
comment:4 Changed 10 years ago by
Use an older version then. We'll get a fix in the next release. We're not doing a new release immediately for one bug. Stop posting these messages everywhere.
comment:6 Changed 10 years ago by
Stop anonymously harrassing people who are trying to help you be a better developer. If you have something to say, say it under your name.
comment:7 follow-up: 8 Changed 10 years ago by
I understand it's not wise to do a new release for the ajax bug ;) ... but in the mean time(so we can carry on testing / debugging our apps ready for the fix) - could someone provide a clearer work around than switch to async - because that makes no difference as far as I can tell.
comment:8 Changed 10 years ago by
Replying to Sam:
I understand it's not wise to do a new release for the ajax bug ;) ... but in the mean time(so we can carry on testing / debugging our apps ready for the fix) - could someone provide a clearer work around than switch to async - because that makes no difference as far as I can tell.
There is one in the first comment.
comment:9 Changed 10 years ago by
Thanks for your time jaubourg. I did read that. Over and over. It just didn't go in. After many hours the penny has dropped. Yes, available in success handler but not useful in dataFilter. I think it's because I'm not very clever. Either that or I'm sitting too close to the screen... come to think of it, my dose does feel a little shorter! I'm going with muppet. Any advances on muppet? Sorry. Thank you. Gone.
comment:10 Changed 10 years ago by
Or just retrieve responseText and parse that. If you can change the output format from the server, even easier to deal with. :)
comment:12 Changed 10 years ago by
dmethvin, when you introduce a bug like that which will definitely break many applications, you should provide an immediate fix and build. You guys should pay more attention on QA before releasing new versions. You should also remember how big is your community and how many apps you will break with such bugs.
comment:13 Changed 10 years ago by
@Ivan, this bug was just introduced on Monday of this week. If it affects your code, just stay with the previous 1.9.0 until 1.9.2 is released.
comment:14 Changed 10 years ago by
Hi, my jquery version shows is 1.6.4 and i used success:function(myData){/*rest of code*/} server response is well formed xml as i checked in firebug. data type in ajax call is set as "xml" and is a get operation. the myData.responseXML is coming as undefined, i tried async:false and async:true but no effect. when i changed the success:function'''(myData,stat,xmlData){...} it works fine.
comment:15 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixes #11151, #13388. Minor refactor of response conversion and when/where responseXXX fields are set on the jqXHR. Close gh-1164. Changeset: 69b3d5ce0f081d3f113b2917495f35df160f8522
comment:16 Changed 10 years ago by
Fixes #11151, #13388. Minor refactor of response conversion and when/where responseXXX fields are set on the jqXHR. Close gh-1164.
(Cherry-picked from 69b3d5ce0f081d3f113b2917495f35df160f8522)
Changeset: eebc77849cebd9a69025996939f930cbf9b1bae1
comment:17 Changed 10 years ago by
I see that the 1.10 beta 1 is out. Will 1.10 include this fix? I have not seen a 1.9.2 beta.
comment:18 Changed 10 years ago by
Milestone: | 1.9.2 → 1.10 |
---|
comment:19 Changed 10 years ago by
Since this is still not fixed in jquery-1.10.1... is there some workaround everyone is using?
comment:20 Changed 10 years ago by
Seems like "this" is fixed, see the fiddle reported above with 1.x selected.
Confirmed, the xml is parsed and accessible in the success handler though, so no need to move to text data. The following works: