Commit bc6e230a by Иван Кубота

Fix ajax response error handling. It was just wrong.

parent f982fc02
...@@ -22,16 +22,18 @@ ...@@ -22,16 +22,18 @@
cb && cb( false, { error: false } ); cb && cb( false, { error: false } );
return; return;
}else if( xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300 ){ }else if( xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300 ){
let json; let json, error = false;
if( cfg.bonus && cfg.bonus.raw ) if( cfg.bonus && cfg.bonus.raw )
return cb && cb( false, xhr ); return cb && cb( false, xhr );
try{ try{
json = JSON.parse( xhr.responseText ); json = JSON.parse( xhr.responseText );
cb && cb( false, json );
}catch( e ){ }catch( e ){
error = true;
json = e;
console.error( 'AJAX:' + method + ' Incorrect Response ← ' + cfg.url, xhr.responseText, e ); console.error( 'AJAX:' + method + ' Incorrect Response ← ' + cfg.url, xhr.responseText, e );
cb && cb( true, e );
} }
cb && cb( error, json );
}else if( xhr.status === 404 ){ }else if( xhr.status === 404 ){
cb && cb( true ); cb && cb( true );
}else if( xhr.status === 503 ){ }else if( xhr.status === 503 ){
......
{ {
"name": "react-vanilla", "name": "react-vanilla",
"version": "1.0.1", "version": "1.1.11",
"description": "", "description": "",
"main": "DOM.js", "main": "DOM.js",
"scripts": { "scripts": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment