Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

fail() handler also fires on HTTP200 and HTTP202

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Fail can also fire because response is not a valid json

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading