Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

$http success callback data undefined in IE (1.2.0 rc3) #4738

Closed
rthomson83 opened this issue Oct 31, 2013 · 6 comments
Closed

$http success callback data undefined in IE (1.2.0 rc3) #4738

rthomson83 opened this issue Oct 31, 2013 · 6 comments

Comments

@rthomson83
Copy link

When using $http like the snippet below, in IE10 the data in the success callback is undefined. When I tested the same in v1.0.8 it worked as expected.

$http({
method: "POST",
url: "SERVICEURL",
responseType: "json",
cache: false
}).success(function(data){});

@rthomson83
Copy link
Author

Done some further investigation and it appears that line 76 in httpBackend.js is causing this. Only in a very specific scenario!

// responseText is the old-school way of retrieving response (supported by IE8 & 9)
// response and responseType properties were introduced in XHR Level2 spec (supported by IE10)
completeRequest(callback,
status || xhr.status,
(xhr.responseType ? xhr.response : xhr.responseText),
responseHeaders);

In Sharepoint 2010, where I'm running the code, in IE10 the page runs in IE8 document standards mode. As responseType is supported in IE10 it has a value of "json", response is not populated because of the IE8 document mode so response is undefined and responseText has a value in this scenario.

@hulbert
Copy link

hulbert commented Dec 12, 2013

Can confirm this is an issue we're seeing with IE8 & IE9. We're doing a pretty basic request and the callback function's data argument is undefined if we set the responseType:

$http({
    method: 'GET',
    url: '/someurl',
    responseType: 'json' // remove this line to make work in IE8,IE9
}).success(function(data, status, headers, config) {
    console.log(data); // logs undefined in IE8, IE9
});

Removing the responseType makes this work, unfortunately. @rthomson83's pull request #4761 fixed it for us on 1.2.0rc and I assumed this was fixed in 1.2.4 but alas it is not. What can we do to get a fix merged, since he closed his?

@rthomson83
Copy link
Author

My fix ended up out of date as another change to the same file was merged before mine. At the time I was too busy to go back and update my fork, re-do the changes again and got a bit disheartened so just closed it and was fully intending to just leave it to the "experts".

It still remains an issue for me so regretting giving up so easily.

@IgorMinar
Copy link
Contributor

I can't reproduce this with Angular 1.2.7 on IE10 in IE8 mode.

Can you please create a plunker demonstrating the problem.

If this really is a problem, then it's an IE bug.

we could work around it with something like:

diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js
index 29f390e..bb708b5 100644
--- a/src/ng/httpBackend.js
+++ b/src/ng/httpBackend.js
@@ -84,7 +84,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc

           if(status !== ABORTED) {
             responseHeaders = xhr.getAllResponseHeaders();
-            response = xhr.responseType ? xhr.response : xhr.responseText;
+            response = ('response' in xhr) ? xhr.response : xhr.responseText;
           }

           // responseText is the old-school way of retrieving response (supported by IE8 & 9)

@IgorMinar
Copy link
Contributor

This issues seems related: #4464

also see comments under this commit: 509ec74

@rthomson83
Copy link
Author

You should be able to dup by using f12 tools and under document standards tab set IE8 document standards instead of standards mode.
This combination of setting in Sharepoint 2010 is set by a meta tag in the master page XUACompatible flag. When IE parses this it sets the document mode or browser mode depending on the value.
SharePoint sp2 has been released with better support for the latest versions of IE.
I need to do a bit of work to see what needs to be changed to get everything working. Once I know what fixes it for me I'll report back here.

jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants