Q:

Use xhr code error on switch/case (javascript)

I'm trying to display some modal depending on the xhr error code, but I don't know why my switch is failing:
error: function (xhr) {
    var codigo_error = parseInt(xhr.status);
    console.log("codigo_error: " + codigo_error);//this shows 404
    switch (codigo_error){
        case 404: body = "Error 404";
        default: body = "Other";
    }
    modal(body);
}

I always get the default case but in console.log I can see the 404. i tried with case '404' but there's no difference.
And if I put if(codigo_error == 404) alert(codigo_error); I can see the alert with 404

A:

I always use a break in my switch cases.
switch(codigo_error){
    case 404:
        body = "Error 404";
        break;
    default:
        body = "Other";
        break;
}
modal(body);

Try that and see if it works.

