Side navigation
#13388 closed bug (fixed)
Opened February 05, 2013 11:50AM UTC
Closed February 28, 2013 07:51PM UTC
Last modified July 31, 2013 12:22AM UTC
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.
Attachments (0)
Change History (20)
Changed February 05, 2013 01:36PM UTC by comment:1
_comment0: | Confirmed, the xml is parsed and accessible in the success handler though, so no need to move to text data. The following works: \ {{{!js \ success: function( xml ) { \ alert(xml.getElementsByTagName("test")[0].childNodes[0].nodeValue); \ } \ }}} → 1360071405738127 |
---|---|
component: | unfiled → ajax |
milestone: | None → 1.9.2 |
owner: | → jaubourg |
priority: | undecided → high |
status: | new → assigned |
version: | git → 1.9.1 |
Changed February 05, 2013 03:45PM UTC by comment:2
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...)
Changed February 06, 2013 03:18AM UTC by comment:3
Please, we need responseXML back.
Changed February 06, 2013 03:34AM UTC by comment:4
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.
Changed February 06, 2013 04:16AM UTC by comment:5
If you guys don't delete people's comments, then I will stop.
Changed February 06, 2013 01:31PM UTC by comment:6
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.
Changed February 06, 2013 02:50PM UTC by comment:7
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.
Changed February 06, 2013 03:10PM UTC by comment:8
Replying to [comment:7 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.
Changed February 06, 2013 04:10PM UTC by comment:9
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.
Changed February 06, 2013 04:20PM UTC by comment:10
Or just retrieve responseText and parse that. If you can change the output format from the server, even easier to deal with. :)
Changed February 08, 2013 12:54PM UTC by comment:11
#13414 is a duplicate of this ticket.
Changed February 08, 2013 02:40PM UTC by comment:12
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.
Changed February 08, 2013 02:47PM UTC by comment:13
@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.
Changed February 13, 2013 11:39AM UTC by comment:14
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.
Changed February 28, 2013 07:51PM UTC by comment:15
Changed February 28, 2013 08:01PM UTC by comment:16
Changed May 24, 2013 04:46AM UTC by comment:17
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.
Changed May 24, 2013 01:30PM UTC by comment:18
milestone: | 1.9.2 → 1.10 |
---|
Changed July 30, 2013 09:47PM UTC by comment:19
Since this is still not fixed in jquery-1.10.1... is there some workaround everyone is using?
Changed July 31, 2013 12:22AM UTC by comment:20
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: