aadsm / JavaScript-ID3-Reader

ID3 tags reader in JavaScript (ID3v1, ID3v2 and AAC)

Home Page:http://www.aadsm.net/libraries/id3/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle CORS errors / documentation

robbeofficial opened this issue · comments

i do not understand how it is possible to handle CORS errors like "No 'Access-Control-Allow-Origin' header is present on the requested resource." the callback provided by ID3.loadTags is only called on success.

i assume it's somehow possible with the dataReader option but could not yet figure out how.

You're right, I completely forgot about that. The XHR data reader does receive an error callback function and it calls it but ID3 was never using it.
I've added a new onError option to loadTags. This function will be called with a reason object. The reason object has an error property that describes the error. If the error is "xhr" then an aditional xhr property is available with the XHR object.

I've put it in a branch first: https://github.com/aadsm/JavaScript-ID3-Reader/tree/gh-28_error-handling

This has been fixed by 4978f96