nl_tokens: Adds 2 methods on the xhr - instance which are used by xhr when events occur :
pl_tokens: function ( xhr , promise ) { // for XDomainRequest, we need "onload" instead of "onreadystatechange" xhr . onreadystatechange = function ( ) { // CANNOT console xhr.responseText here! IE9 will throw an error: // you can only acces it after (xhr.readyState===4) // also check xhr._aborted --> IE9 comes here after aborted and will throw an error when reading xhr"s native properties if ( ! xhr . _aborted && ( xhr . readyState === 4 ) ) { clearTimeout ( xhr . _timer ) ; if ( ( xhr . status >= 200 ) && ( xhr . status < 300 ) ) { // In case streamback function is set, but when no intermediate stream-data was send // (or in case of XDR: below 2kb it doesn"t call onprogress) // --> we might need to call onprogress ourselve. if ( xhr . _isStream && ! xhr . _gotstreamed ) { xhr . onprogress ( xhr . responseText ) ; } if ( xhr . _fileProgress && ! xhr . _gotstreamed ) { xhr . onprogress ( { lengthComputable : true , loaded : 1 , <mask> : 1 } ) ; } promise . fulfill ( xhr ) ; } else { promise . reject ( xhr . statusText || ( UNKNOW_ERROR ) ) ; } } } ; xhr . onerror = function ( ) { clearTimeout ( xhr . _timer ) ; promise . reject ( XHR_ERROR ) ; } ; }