Replace jQuery ajax calls with Axios
Background
With our effort towards replacing all ajax calls with Axios as seen in https://gitlab.com/gitlab-org/gitlab-ce/issues/39727 and our effort towards upgrading jQuery to 3.0 https://gitlab.com/gitlab-org/gitlab-ce/issues/33888.
Recommendation
I recommend that we first replace all jQuery ajax calls with Axios separately before we continue the migration work for upgrading jQuery to 3.0. We should do this separately because the jQuery migration has a few breaking changes related to ajax that are more difficult to test. By transitioning over to Axios, we will save more time in the long run, since we no longer have to test these jQuery migration changes related to ajax and we are helping with the transition towards replacing all ajax calls with Axios.
jQuery 3.0 ajax changes
- Breaking change: Special-case Deferred methods removed from jQuery.ajax
- Breaking change: Cross-domain script requests must be declared
- Breaking change: Hash in a URL is preserved in a jQuery.ajax() call
- Feature: New signature for jQuery.get() AND jQuery.post()
Tentative Plan
- Go through each occurrence in CE and fix it
- Create MR to fix CE and EE at the same time
- After all CE occurrences are fixed, create EE MRs to fix EE only occurrrences
Estimated level of effort
CE
- 86 occurrences of
$.ajax
according togit grep -w $.ajax | wc -l
- 4 occurrences of
$.post
according togit grep -w $.post | wc -l
- 12 occurrences of
$.get
according togit grep -w $.get | wc -l
EE
- 100 occurrences of
$.ajax
according togit grep -w $.ajax | wc -l
- 4 occurrences of
$.post
according togit grep -w $.post | wc -l
- 12 occurrences of
$.get
according togit grep -w $.get | wc -l
Files impacted (CE)
Generated using
git grep -c -w $.ajax
$.ajax
-
app/assets/javascripts/api.js:9 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16717 -
app/assets/javascripts/blob/viewer/index.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16717 -
app/assets/javascripts/commits.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16717 -
app/assets/javascripts/compare.js:2 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16731 -
app/assets/javascripts/compare_autocomplete.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16731 -
app/assets/javascripts/create_merge_request_dropdown.js:4 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16731 -
app/assets/javascripts/dropzone_input.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16731 -
app/assets/javascripts/due_date_select.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16731 -
app/assets/javascripts/filterable_list.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16731 -
app/assets/javascripts/gl_dropdown.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16761 -
app/assets/javascripts/graphs/graphs_show.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16761 -
app/assets/javascripts/group_label_subscription.js:2 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16761 -
app/assets/javascripts/groups_select.js:1 @iamphill -
app/assets/javascripts/integrations/integration_settings_form.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16761 -
app/assets/javascripts/issuable_bulk_update_actions.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16761 -
app/assets/javascripts/issuable_index.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16761 -
app/assets/javascripts/issue.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/job.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/label_manager.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16695 -
app/assets/javascripts/labels_select.js:2 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/lib/utils/ajax_cache.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/lib/utils/common_utils.js:3 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/merge_conflicts/merge_conflict_service.js:2 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/merge_request_tabs.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/milestone.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/milestone_select.js:2 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
app/assets/javascripts/mini_pipeline_graph_dropdown.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
app/assets/javascripts/network/branch_graph.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
app/assets/javascripts/notes.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
app/assets/javascripts/notifications_form.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
app/assets/javascripts/pager.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16840 -
app/assets/javascripts/pages/admin/cohorts/usage_ping.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
app/assets/javascripts/pages/dashboard/todos/index/todos.js:2 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
app/assets/javascripts/pages/projects/project.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16873 -
app/assets/javascripts/pages/sessions/new/username_validator.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16892 -
app/assets/javascripts/preview_markdown.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16893 -
app/assets/javascripts/profile/profile.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16895 -
app/assets/javascripts/project_find_file.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16841 -
app/assets/javascripts/project_label_subscription.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882 -
app/assets/javascripts/prometheus_metrics/prometheus_metrics.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882 -
app/assets/javascripts/protected_branches/protected_branch_edit.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882 -
app/assets/javascripts/protected_tags/protected_tag_edit.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882 -
app/assets/javascripts/right_sidebar.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882 -
app/assets/javascripts/shortcuts.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882 -
app/assets/javascripts/task_list.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882 -
app/assets/javascripts/users/activity_calendar.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16839 -
app/assets/javascripts/users/user_tabs.js:2 @iamphill -
app/assets/javascripts/users_select.js:3 @iamphill -
spec/javascripts/blob/viewer/index_spec.js:8 @iamphill -
spec/javascripts/integrations/integration_settings_form_spec.js:1 @iamphill -
spec/javascripts/lib/utils/ajax_cache_spec.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
spec/javascripts/lib/utils/common_utils_spec.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16800 -
spec/javascripts/pager_spec.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16848 -
spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16882
$.post
-
app/assets/javascripts/awards_handler.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16685 -
app/assets/javascripts/blob_edit/edit_blob.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16693 -
app/assets/javascripts/importer_status.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16692 -
app/assets/javascripts/label_manager.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16695
$.get
-
app/assets/javascripts/api.js:3 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16717 -
app/assets/javascripts/boards/components/new_list_dropdown.js:1 @okoghenun https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16992 -
app/assets/javascripts/diff.js:1 @okoghenun https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16989 -
app/assets/javascripts/gpg_badges.js:1 @okoghenun https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16989 -
app/assets/javascripts/importer_status.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/17122 -
app/assets/javascripts/merge_conflicts/components/diff_file_editor.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16896 -
app/assets/javascripts/render_math.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16697 -
app/assets/javascripts/search_autocomplete.js:1 @iamphill https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16943 -
app/assets/javascripts/single_file_diff.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16696
EE
$.ajax
-
app/assets/javascripts/members.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4473 -
app/assets/javascripts/mirrors/mirror_pull.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4474 -
ee/app/assets/javascripts/approvers_select.js:2 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4476 -
ee/app/assets/javascripts/weight_select.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4525
$.post
-
ee/app/assets/javascripts/path_locks.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4516
$.getJSON
-
app/assets/javascripts/mirrors/mirror_pull.js:1 @ClemMakesApps https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4517