Home > OS >  fail() handler also fires on HTTP200 and HTTP202
fail() handler also fires on HTTP200 and HTTP202

Time:01-19

I have this simple code:

function dlgEditPhase_okClicked(dlgEditPhase, event) {
    $.post("/overview/phase/" dlgEditPhase.projectId, 
        JSON.stringify({
            "phaseName": dlgEditPhase.phaseName,
            "begin": dlgEditPhase.begin,
            "end": dlgEditPhase.end
        }),
        function(data) {
            dlgEditPhase.close();
            location.reload();
        },
        "json"
    ).fail(function(data) {
        alert(data.responseJSON);
    });
}

Problem is, the fail is always fired, even when the POST call returns code 200 or 202.

What am I doing wrong?

CodePudding user response:

Fail can also fire because response is not a valid json

  •  Tags:  
  • Related