adlnet / xAPIWrapper

Wrapper to simplify communication to an LRS
https://adlnet.gov/projects/xapi/
Apache License 2.0
219 stars 114 forks source link

Cross Domain and IE10 #56

Closed f1hornet closed 8 years ago

f1hornet commented 8 years ago

Hey when I try to use this with IE10 (works great with ie11, chrome) I get an error:

SCRIPT5: Access is denied. xapiwrapper.js, line 1342 character 13

This is the line it refers to: xhr.open(ieModeRequest.method, ieModeRequest.url);

Any ideas how to fix this - having the course on a secure server makes no diffence.

Sorry - pressed submit before adding the error!

John

creighton commented 8 years ago

what's the error?

f1hornet commented 8 years ago

Hi Creighton - I updated my comment now

f1hornet commented 8 years ago

trying to connect to a WAX LRS: https://isl.waxlrs.com/TCAPI/

creighton commented 8 years ago

hmm.. ok. we'll try it out here and see what we can find.. sorry I don't have a quick answer for you

f1hornet commented 8 years ago

Thanks for your help... I reverted back to your example.html file as a simple example to try and debug the issue but I'm not making any progress. We are running it from a http connection to the https LRS but even moving the file to https made no difference. As I mentioned before it works perfectly in IE11 and Chrome but our client wants it on older browsers - even as far back as IE8! :(

I really appreciate any help you can provide.

f1hornet commented 8 years ago

Hi Tom, I came up with a solution that seems to be working:

Change: //If it's not cross domain or we're not using IE, use the usual XmlHttpRequest if (!xDomainRequest || typeof(XDomainRequest) === 'undefined') {

To:

//If it's not cross domain or we're not using IE, use the usual XmlHttpRequest var windowsVersionCheck = window.XDomainRequest && (window.XMLHttpRequest && new XMLHttpRequest().responseType === undefined); if (!xDomainRequest || windowsVersionCheck === undefined || windowsVersionCheck===false) {

based on this article: http://stackoverflow.com/questions/15460152/how-to-determine-whether-to-use-xmlhttprequest-or-xdomainrequest

Let me know if you think this will work

thanks

John

ljwolford commented 8 years ago

Hi John,

We tested it on our side and it appears to be working. Thank you for finding this bug and fixing it! I'll be creating a pull request to include it in the code.

shigil commented 7 years ago

Hi

I ran into a problem while using this API with IE10. The API was throwing invalid state error in IE 10 while trying to fetch statements.

Debugging further I realized that the issue was actually with the xhr.withCredentials in the ADL.XHR_request function. Moving it after xhr.open fixed the issue. Is it possible to raise a pull request to include it in the code?

xhr.open(method, url, callback != null); xhr.withCredentials = withCredentials;