diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-02-05 18:03:24 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2018-02-05 18:03:24 +0300 |
commit | 2fe09e6a12e4f533d77517ddd7fe40fc53522f92 (patch) | |
tree | dabb96705c6abced6c0232b7a4f9f3f7df111ef8 /app | |
parent | 5e74a363560251dbccb49ab7f281ae8e5be6ddb0 (diff) | |
parent | 11df0c231fe23a853e8758c7a0e3cc6de948dc63 (diff) |
Merge branch 'axios-preview-markdown' into 'master'
Replace $.ajax in preview markdown with axios
See merge request gitlab-org/gitlab-ce!16893
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/preview_markdown.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/app/assets/javascripts/preview_markdown.js b/app/assets/javascripts/preview_markdown.js index 86c7b56198d..464bfb351e7 100644 --- a/app/assets/javascripts/preview_markdown.js +++ b/app/assets/javascripts/preview_markdown.js @@ -7,6 +7,10 @@ // more than `x` users are referenced. // +import axios from '~/lib/utils/axios_utils'; +import flash from '~/flash'; +import { __ } from '~/locale'; + var lastTextareaPreviewed; var lastTextareaHeight = null; var markdownPreview; @@ -62,21 +66,17 @@ MarkdownPreview.prototype.fetchMarkdownPreview = function (text, url, success) { success(this.ajaxCache.response); return; } - $.ajax({ - type: 'POST', - url: url, - data: { - text: text - }, - dataType: 'json', - success: (function (response) { - this.ajaxCache = { - text: text, - response: response - }; - success(response); - }).bind(this) - }); + axios.post(url, { + text, + }) + .then(({ data }) => { + this.ajaxCache = { + text: text, + response: data, + }; + success(data); + }) + .catch(() => flash(__('An error occurred while fetching markdown preview'))); }; MarkdownPreview.prototype.hideReferencedUsers = function ($form) { |