Skip to content
This repository has been archived by the owner on Dec 20, 2020. It is now read-only.

'xmlhttprequest.responsetype json is not supported' #94

Closed
Rob-pw opened this issue Dec 17, 2015 · 6 comments
Closed

'xmlhttprequest.responsetype json is not supported' #94

Rob-pw opened this issue Dec 17, 2015 · 6 comments

Comments

@Rob-pw
Copy link
Contributor

Rob-pw commented Dec 17, 2015

Hi:

First, thanks for creating this library, we've found it to be very useful and reliable.

We're currently encountering the error: 'xmlhttprequest.responsetype json is not supported' in Blackberry 10.2.0, this is likely due to the older version of webkit it uses.

Separately, installing via 'bower install qwest' seems to miss out the pinkyswear library, we had to use the npm variant.

Thanks for any assistance!

@pyrsmk
Copy link
Owner

pyrsmk commented Dec 17, 2015

Hi!

Thanks for loving qwest ;)

First, for bower. PinkySwear is not published at all on it. You can only use the built versions of qwest : qwest.js or qwest.min.js.

For your issue, can you use the non-minified file of qwest and tell me which line is crashing?

@Rob-pw
Copy link
Contributor Author

Rob-pw commented Dec 17, 2015

Understood, we're now just using npm.

Through the chrome debugger attached to the emulated Blackberry, it is reporting line: https://github.com/pyrsmk/qwest/blob/master/qwest.js#L248. However I suspect it to be https://github.com/pyrsmk/qwest/blob/master/qwest.js#L294, as options.responseType is 'json', but the property is never set (value stays as ''), though the error doesn't appear until after the response is received (we believe).

@pyrsmk
Copy link
Owner

pyrsmk commented Dec 18, 2015

That's what I expected, but that line shouldn't throw any error since it's wrapped by a try/catch control. And the condition has been passed so Blackberry should support XHR2 types :s

It seems Blackberry doesn't support XHR2 types, but the condition shouldn't pass. The xhr2 variable is set to true when it should not : https://github.com/pyrsmk/qwest/blob/master/qwest.js#L196

On that line, I'm verifying that XHR2 is supported by comparing responseType to an empty string because if XHR2 is not supported then responseType should be undefined.

Anyway! It seems you're explicitly setting the qwest's responseType option to json, isn't it? It's not needed since qwest can cleverly detect what data is expected based on the Content-Type header of the response. Can you leave responseType to auto and tell me if it's working?

@pyrsmk
Copy link
Owner

pyrsmk commented Dec 18, 2015

I'll enhance XHR2 detection based on Modernizr's tests : https://gist.github.com/paulirish/1431660#file_xhr2.js

@Rob-pw
Copy link
Contributor Author

Rob-pw commented Dec 18, 2015

Curiously it doesn't seem to be 'throwing' an error, but it is definitely logged.

I'm unsure as to the best approach but I guess you could try assigning the responseType, then check if it was indeed set or if it is now an empty string again, though that would probably still log the responseType error.

Apologies for taking a while to respond to this, changing responseType to be auto did resolve the issue. Thanks for your help! :)

@pyrsmk
Copy link
Owner

pyrsmk commented Dec 18, 2015

It's not crashing your code even if the error is logged? That's great news! And I'm glad that setting responseType to auto is working ;)

For the issue, if I assign an unsupported value to responseType, it will probably log the same error even if it's catched. Moreover, I was wrong when I said that Blackberry doesn't seem to support XHR2 because the logged message shows us that it supports it, but just not json response type.

I think I'll just put a notice on the docs for now. Thanks for reported it anyway!

@pyrsmk pyrsmk closed this as completed Dec 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants