diff options
| author | Clement Ho <ClemMakesApps@gmail.com> | 2018-02-02 12:42:43 -0600 |
|---|---|---|
| committer | Clement Ho <ClemMakesApps@gmail.com> | 2018-02-02 12:42:43 -0600 |
| commit | 22522135c0734502e1bd80fd5b167359796817b0 (patch) | |
| tree | c96417cc1595e3fb6ec2d330ef16be0f83b6fecb | |
| parent | f88fbd2d839629b130ca0d705a70df696c3a3047 (diff) | |
| download | gitlab-ce-22522135c0734502e1bd80fd5b167359796817b0.tar.gz | |
Replace $.ajax in preview markdown with axios
| -rw-r--r-- | app/assets/javascripts/preview_markdown.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/app/assets/javascripts/preview_markdown.js b/app/assets/javascripts/preview_markdown.js index 86c7b56198d..c5c2594a3ac 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,19 @@ MarkdownPreview.prototype.fetchMarkdownPreview = function (text, url, success) { success(this.ajaxCache.response); return; } - $.ajax({ - type: 'POST', - url: url, + axios.post(url, { data: { - text: text + text, }, - dataType: 'json', - success: (function (response) { - this.ajaxCache = { - text: text, - response: response - }; - success(response); - }).bind(this) - }); + }) + .then(({ data }) => { + this.ajaxCache = { + text: text, + response: data, + }; + success(data); + }) + .catch(() => flash(__('An error occurred while fetching markdown preview'))); }; MarkdownPreview.prototype.hideReferencedUsers = function ($form) { |
