From ad00ede6cb924facd44461282c9b76e580836c6b Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 14 Nov 2019 09:28:25 +0300 Subject: [PATCH] Correctly printing license generation error --- src/index.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/index.js b/src/index.js index a181ef5..d295272 100644 --- a/src/index.js +++ b/src/index.js @@ -27,18 +27,17 @@ document.addEventListener("DOMContentLoaded", () => { notify("#d32f2f", message); }; window.onSubmit = function() { - $.post(apiEndpoint, $("form#license-form").serialize()) - .done(function(evt, status, xhr) { - if (xhr.status === 200) { - success("An evaluation license key was sent to your email address"); - } else { - failure(`An error while requesting evaluation license key: ${xhr.statusText}`); - } + $.ajax({ + url: apiEndpoint, + data: $("form#license-form").serialize(), + success: function() { + success("An evaluation license key was sent to your email address"); reset(); - }) - .fail(function(e) { - failure(`Failed to request evaluation license key: ${e.statusText}`); + }, + error: function(xhr) { + failure(`Failed to request evaluation license key: ${xhr.responseText}`); reset(); - }); + } + }); }; });