larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
222 stars 30 forks source link

unable to fetch citation response in ie 11 #180

Open vivek1395068 opened 5 years ago

vivek1395068 commented 5 years ago

The following error i am getting in the browser console:- "SCRIPT8: The download of the specified resource has failed."

while it works fine in mozilla and chrome browsers with the following warning in the console:- "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/".

I tried debugging the library and found that there xhr have been used and also trying to make synchronous api call. So i think that is the issue with ie and edge, the synchronous api calls are getting deprecated.

So can anyone please update the library, and make an asynchronous call instead of synchronous one or find some another solution for that. It will be a great help. Thanks

larsgw commented 5 years ago

Thank you for your question. There is already an asynchronous API:

// Callback
Cite.async(input, function callback (/* <Cite> */ data) { ... })

// Promise
Cite.async(input) // Promise<Cite>, use with `.then()` or `await`
vivek1395068 commented 5 years ago

Thanks for the reply :). But still I am getting the same error in the console while i am using promise :-

// Promise Cite.async(input)

in ie 11:- error:-"The download of the specified resource has failed."

while the warning messages in chrome and mozilla browsers are gone.

Is this because we are using fetch api in the library?

larsgw commented 5 years ago

The polyfill that Citation.js uses should support IE 10+. Can you share the input you're having problems with?

vivek1395068 commented 5 years ago

Please find the following code which i am using:- var opt = { format: "string", type: "string", style: "bibtxt", lang: "en-US" }; Cite.async("10.7717/peerj-cs.52").then((cite)=>{ var output = cite.get(opt); console.log(output) }).catch((error)=>{ console.log(error.message); });

The above code is getting executed on click of a button .

in ie 11 console :- error:-"The download of the specified resource has failed." ie11_error

larsgw commented 5 years ago

The main difference between the Firefox & Chrome code and the IE11 code is the Fetch API polyfill, which isn't usually applied on Chrome & Firefox since they have it natively already. However, it seems to be working fine for me (both synchronously and asynchronously) when I test it in IE11 on Browserstack. I might be able to test on a real machine with IE11 in a few days, I'll report back if I find it out.

For the record, the error code apparently corresponds to INET_E_DOWNLOAD_FAILURE (0x800C0008), with the following description:

The download has failed (the connection was interrupted).

vivek1395068 commented 5 years ago

Sure Thanks.

larsgw commented 5 years ago

What version of Citation.js are you using?

vivek1395068 commented 5 years ago

Actually I have included it in my index.html file like this :-

also one more thing, is this related to CORS issue because in network i am able to see that we are making a call to "https://data.crossref.org/10.7717/peerj-cs.52" api ?