-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observable.ajax response is string for IE11 #1381
Comments
I got interested in this and try to reproduce it, but for some reason I wasn't able to do so. I assume I've done something incorrectly.. @gbabiars , would you mind to share some details how I can reproduce this one? |
I can't reproduce this either. So I'm removing the bug label for now. |
@gbabiars can you show the full request and response headers that produced this issue? |
A plunker or codepen or something like that would help. |
I've created a repo at https://github.com/gbabiars/rxjs-ajax-repro since ajax is not included in the npmcdn build. The request I'm doing is a CORS request over http (the original was https, so that does not appear to matter). The repro demo appends the actual type of the response property and the value of the responseType. On Chrome, I get an object for response and responseType is json. On IE11, I am getting string for response and responseType is empty. I will try to do some more investigating into this, but hopefully this helps for repro steps. |
Thanks! trying now... |
OK, could reproduce issue. Able to confirm XHR responseType is empty instead of being set to json, and after digging into bit more it seems like IE doesn't support json as responseType (https://msdn.microsoft.com/en-us/library/hh872882(v=vs.85).aspx) while other browser (Chrome > 31, Firefox > 10, https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType / http://caniuse.com/#search=XMLHttpRequest) implemented it. Should ajax implementation takes care of parsing json on IE? Seems there are some of IE specific handling ( |
- IE does not support json responseType, internally parse it into JSON object closes ReactiveX#1381
- IE does not support json responseType, internally parse it into JSON object closes ReactiveX#1381
* Return null value from JSON.Parse JSON.parse('') will throw a syntax error (in any browser). Fix is to return a null value. I saw this when my server returned HTTP 204 No Content. * added ajax tests for 204 No Content * mock the behavior of IE unit test for IE * pascal case class name. added missing semicolon. * Use 'null' instead of '' for JSON.parse * remove empty constructor * fix(AjaxObservable): return null value from JSON.Parse JSON.parse('') will throw a syntax error (in any browser). Fix is to return a null value. This happens during an HTTP 204 'No Content' in IE. Added a mock for InternetExplorer. Added unit tests for HTTP 204. closes #1381
Hi, I run into similar problem with 400 response.
Non 2xx status responses fall under AjaxError constructor which does non of the IE magic that AjaxResponse constructor does, see: AjaxObservable.ts#L451. Is that on purpose or should be fixed? (Happy to help here) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm seeing an issue on 5.0.0-beta.2 where the ajax observable returns plain text when
responseType
is either set tojson
or left blank.Example:
For a payload that is an Array,
res.response
is of type Array in Chrome, however, on IE11 it is a string. Digging into it, it appears theresponseType
property on the xhr at https://github.com/ReactiveX/RxJS/blob/master/src/observable/dom/AjaxObservable.ts#L353 appears to always be empty, regardless of whatrequest.responseType
was at https://github.com/ReactiveX/RxJS/blob/master/src/observable/dom/AjaxObservable.ts#L215.This is easy enough to work around in the resultSelector:
The text was updated successfully, but these errors were encountered: