$('#twofactor_form').on('submit', function(event) { var formData = $('#twofactor_form').serialize(); event.preventDefault(); $.ajax({ url: 'api/userLogin', method: 'POST', data: JSON.stringify(formData), dataType: 'json', beforeSend: null, error: function(event) { alert(event.responseJSON.error); //debugger; }, success: function(data) { //Note this never gets tripped ever. //It never reaches the success or failure state, it just spits out that raw html and my url points to the api.pm path. if ( data._resume ) { //console.log("2FA _resume hit"); var resume = JSON.parse(data._resume); window.location.replace(resume.url); } else { //console.log("2FA no-resume hit"); window.location.replace(BASE_URL); } } }); return false; });