diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js b/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js
index 2e41ed62..eabd79ba 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.js
@@ -201,17 +201,15 @@ define('pgadmin.node.cast', [
                 cache: false,
                 async: false,
                 data: {'srctyp' : srcTyp, 'trgtyp' : trgtyp},
-
-                 // On success return function list from server
-                success: function(result) {
-                  res = result.data;
-                  return res;
-                },
-
-                 // On failure show error appropriate error message to user
-                error: function(xhr, status, error) {
-                  alertify.pgRespErrorNotify(xhr, error);
-                },
+              })
+               // On success return function list from server
+              .done(function(result) {
+                res = result.data;
+                return res;
+              })
+               // On failure show error appropriate error message to user
+              .fail(function(xhr, status, error) {
+                alertify.pgRespErrorNotify(xhr, error);
               });
             }
             return res;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js
index 24f5e1a7..4da0a2d0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.js
@@ -350,17 +350,17 @@ define('pgadmin.node.foreign_table', [
           async: false,
           url: full_url,
           data: data,
-          success: function(res) {
-            /*
-             * We will cache this data for short period of time for avoiding
-             * same calls.
-             */
-            data = cache_node.cache(url, node_info, cache_level, res.data);
-
-          },
-          error: function() {
-            m.trigger('pgadmin:view:fetch:error', m, self.field);
-          },
+        })
+        .done(function(res) {
+          /*
+           * We will cache this data for short period of time for avoiding
+           * same calls.
+           */
+          data = cache_node.cache(url, node_info, cache_level, res.data);
+
+        })
+        .fail(function() {
+          m.trigger('pgadmin:view:fetch:error', m, self.field);
         });
         m.trigger('pgadmin:view:fetched', m, self.field);
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js
index cba62789..935cc84c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.js
@@ -111,20 +111,20 @@ define('pgadmin.node.fts_configuration', [
                     $.ajax({
                       async: false,
                       url: full_url,
-                      success: function(res) {
-                      /*
-                       * We will cache this data for short period of time for
-                       * avoiding same calls.
-                       */
-                        data = cache_node.cache(url,
-                                 node_info,
-                                 cache_level,
-                                 res.data
-                               );
-                      },
-                      error: function() {
-                        m.trigger('pgadmin:view:fetch:error', m, self.field);
-                      },
+                    })
+                    .done(function(res) {
+                    /*
+                     * We will cache this data for short period of time for
+                     * avoiding same calls.
+                     */
+                      data = cache_node.cache(url,
+                               node_info,
+                               cache_level,
+                               res.data
+                             );
+                    })
+                    .fail(function() {
+                      m.trigger('pgadmin:view:fetch:error', m, self.field);
                     });
                     m.trigger('pgadmin:view:fetched', m, self.field);
                   }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js
index 3b9b0f35..43f9cfda 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js
@@ -31,12 +31,12 @@ define('pgadmin.node.schema', [
           $.ajax({
             async: false,
             url: full_url,
-            success: function (res) {
-              data = res;
-            },
-            error: function() {
-              m.trigger('pgadmin-view:fetch:error', m, self.field);
-            },
+          })
+          .done(function (res) {
+            data = res;
+          })
+          .fail(function() {
+            m.trigger('pgadmin-view:fetch:error', m, self.field);
           });
           m.trigger('pgadmin-view:fetched', m, self.field);
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js
index 25fa40f7..a146dabc 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.js
@@ -154,17 +154,15 @@ define('pgadmin.node.synonym', [
               cache: false,
               async: false,
               data: {'trgTyp' : trgTyp, 'trgSchema' : trgSchema},
-
-                  // On success return function list from server
-              success: function(result) {
-                res = result.data;
-                return res;
-              },
-
-                  // On failure show error appropriate error message to user
-              error: function(xhr, status, error) {
-                alertify.pgRespErrorNotify(xhr, error);
-              },
+            })
+            // On success return function list from server
+            .done(function(result) {
+              res = result.data;
+              return res;
+            })
+            // On failure show error appropriate error message to user
+            .fail(function(xhr, status, error) {
+              alertify.pgRespErrorNotify(xhr, error);
             });
             return res;
           },
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js
index d8dc2ae7..05722546 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.js
@@ -61,21 +61,21 @@ define('pgadmin.node.check_constraint', [
           $.ajax({
             url: obj.generate_url(i, 'validate', d, true),
             type:'GET',
-            success: function(res) {
-              if (res.success == 1) {
-                alertify.success(res.info);
-                t.removeIcon(i);
-                data.valid = true;
-                data.icon = 'icon-check_constraint';
-                t.addIcon(i, {icon: data.icon});
-                setTimeout(function() {t.deselect(i);}, 10);
-                setTimeout(function() {t.select(i);}, 100);
-              }
-            },
-            error: function(xhr, status, error) {
-              alertify.pgRespErrorNotify(xhr, error);
-              t.unload(i);
-            },
+          })
+          .done(function(res) {
+            if (res.success == 1) {
+              alertify.success(res.info);
+              t.removeIcon(i);
+              data.valid = true;
+              data.icon = 'icon-check_constraint';
+              t.addIcon(i, {icon: data.icon});
+              setTimeout(function() {t.deselect(i);}, 10);
+              setTimeout(function() {t.select(i);}, 100);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            alertify.pgRespErrorNotify(xhr, error);
+            t.unload(i);
           });
 
           return false;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js
index adccf2e9..8b097034 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.js
@@ -82,13 +82,13 @@ define('pgadmin.node.exclusion_constraint', [
                 async: false,
                 data : {indextype:indextype},
                 url: full_url,
-                success: function(res) {
-                  data = res.data;
-                  self.column.set('options', data);
-                },
-                error: function() {
-                  eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
-                },
+              })
+              .done(function(res) {
+                data = res.data;
+                self.column.set('options', data);
+              })
+              .fail(function() {
+                eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
               });
               eventHandler.trigger('pgadmin:view:fetched', m, self.column);
             }
@@ -183,13 +183,13 @@ define('pgadmin.node.exclusion_constraint', [
                 async: false,
                 data : {col_type:col_type},
                 url: full_url,
-                success: function(res) {
-                  data = res.data;
-                  self.column.set('options', data);
-                },
-                error: function() {
-                  eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
-                },
+              })
+              .done(function(res) {
+                data = res.data;
+                self.column.set('options', data);
+              })
+              .fail(function() {
+                eventHandler.trigger('pgadmin:view:fetch:error', m, self.column);
               });
               eventHandler.trigger('pgadmin:view:fetched', m, self.column);
             }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js
index 9899df92..9d11ec7f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.js
@@ -214,12 +214,12 @@ define('pgadmin.node.foreign_key', [
                       async: false,
                       data : {tid:tid},
                       url: full_url,
-                      success: function(res) {
-                        data = res.data;
-                      },
-                      error: function() {
-                        m.trigger('pgadmin:view:fetch:error', m, self.field);
-                      },
+                    })
+                    .done(function(res) {
+                      data = res.data;
+                    })
+                    .fail(function() {
+                      m.trigger('pgadmin:view:fetch:error', m, self.field);
                     });
                     m.trigger('pgadmin:view:fetched', m, self.field);
                   }
@@ -558,12 +558,12 @@ define('pgadmin.node.foreign_key', [
               async: false,
               data : {cols:JSON.stringify(cols)},
               url: full_url,
-              success: function(res) {
-                coveringindex = res.data;
-              },
-              error: function() {
-                m.trigger('pgadmin:view:fetch:error', m, self.field);
-              },
+            })
+            .done(function(res) {
+              coveringindex = res.data;
+            })
+            .fail(function() {
+              m.trigger('pgadmin:view:fetch:error', m, self.field);
             });
             m.trigger('pgadmin:view:fetched', m, self.field);
           }
@@ -653,21 +653,21 @@ define('pgadmin.node.foreign_key', [
           $.ajax({
             url: obj.generate_url(i, 'validate', d, true),
             type:'GET',
-            success: function(res) {
-              if (res.success == 1) {
-                Alertify.success(res.info);
-                t.removeIcon(i);
-                data.valid = true;
-                data.icon = 'icon-foreign_key';
-                t.addIcon(i, {icon: data.icon});
-                setTimeout(function() {t.deselect(i);}, 10);
-                setTimeout(function() {t.select(i);}, 100);
-              }
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
-              t.unload(i);
-            },
+          })
+          .done(function(res) {
+            if (res.success == 1) {
+              Alertify.success(res.info);
+              t.removeIcon(i);
+              data.valid = true;
+              data.icon = 'icon-foreign_key';
+              t.addIcon(i, {icon: data.icon});
+              setTimeout(function() {t.deselect(i);}, 10);
+              setTimeout(function() {t.select(i);}, 100);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
+            t.unload(i);
           });
 
           return false;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
index 74649721..ecb28e16 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
@@ -134,21 +134,21 @@ function(
             type:'PUT',
             data: params,
             dataType: 'json',
-            success: function(res) {
-              if (res.success == 1) {
-                Alertify.success(res.info);
-                t.unload(i);
-                t.setInode(i);
-                t.deselect(i);
-                setTimeout(function() {
-                  t.select(i);
-                }, 10);
-              }
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
+          })
+          .done(function(res) {
+            if (res.success == 1) {
+              Alertify.success(res.info);
               t.unload(i);
-            },
+              t.setInode(i);
+              t.deselect(i);
+              setTimeout(function() {
+                t.select(i);
+              }, 10);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
+            t.unload(i);
           });
         },
         /* Truncate table */
@@ -182,25 +182,25 @@ function(
                   type:'PUT',
                   data: params,
                   dataType: 'json',
-                  success: function(res) {
-                    if (res.success == 1) {
-                      Alertify.success(res.info);
-                      t.removeIcon(i);
-                      data.icon = 'icon-partition';
-                      t.addIcon(i, {icon: data.icon});
-                      t.unload(i);
-                      t.setInode(i);
-                      t.deselect(i);
-                    // Fetch updated data from server
-                      setTimeout(function() {
-                        t.select(i);
-                      }, 10);
-                    }
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error);
+                })
+                .done(function(res) {
+                  if (res.success == 1) {
+                    Alertify.success(res.info);
+                    t.removeIcon(i);
+                    data.icon = 'icon-partition';
+                    t.addIcon(i, {icon: data.icon});
                     t.unload(i);
-                  },
+                    t.setInode(i);
+                    t.deselect(i);
+                  // Fetch updated data from server
+                    setTimeout(function() {
+                      t.select(i);
+                    }, 10);
+                  }
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error);
+                  t.unload(i);
                 });
               }},
             function() {}
@@ -225,25 +225,25 @@ function(
                 $.ajax({
                   url: obj.generate_url(i, 'reset' , d, true),
                   type:'DELETE',
-                  success: function(res) {
-                    if (res.success == 1) {
-                      Alertify.success(res.info);
-                      t.removeIcon(i);
-                      data.icon = 'icon-partition';
-                      t.addIcon(i, {icon: data.icon});
-                      t.unload(i);
-                      t.setInode(i);
-                      t.deselect(i);
-                      // Fetch updated data from server
-                      setTimeout(function() {
-                        t.select(i);
-                      }, 10);
-                    }
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error);
+                })
+                .done(function(res) {
+                  if (res.success == 1) {
+                    Alertify.success(res.info);
+                    t.removeIcon(i);
+                    data.icon = 'icon-partition';
+                    t.addIcon(i, {icon: data.icon});
                     t.unload(i);
-                  },
+                    t.setInode(i);
+                    t.deselect(i);
+                    // Fetch updated data from server
+                    setTimeout(function() {
+                      t.select(i);
+                    }, 10);
+                  }
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error);
+                  t.unload(i);
                 });
               }
             },
@@ -268,26 +268,26 @@ function(
                 $.ajax({
                   url: obj.generate_url(i, 'detach' , d, true),
                   type:'PUT',
-                  success: function(res) {
-                    if (res.success == 1) {
-                      Alertify.success(res.info);
-                      var n = t.next(i);
+                })
+                .done(function(res) {
+                  if (res.success == 1) {
+                    Alertify.success(res.info);
+                    var n = t.next(i);
+                    if (!n || !n.length) {
+                      n = t.prev(i);
                       if (!n || !n.length) {
-                        n = t.prev(i);
-                        if (!n || !n.length) {
-                          n = t.parent(i);
-                          t.setInode(n, true);
-                        }
-                      }
-                      t.remove(i);
-                      if (n.length) {
-                        t.select(n);
+                        n = t.parent(i);
+                        t.setInode(n, true);
                       }
                     }
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error);
-                  },
+                    t.remove(i);
+                    if (n.length) {
+                      t.select(n);
+                    }
+                  }
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error);
                 });
               }
             },
@@ -874,19 +874,19 @@ function(
 
                   type: 'GET',
                   async: false,
-                  success: function(res) {
-                    if (res.success == 1) {
-                      self.model.table_options = res.data;
-                    }
-                    else {
-                      Alertify.alert(
-                        gettext('Error fetching tables to be attached'), res.data.result
-                      );
-                    }
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached'));
-                  },
+                })
+                .done(function(res) {
+                  if (res.success == 1) {
+                    self.model.table_options = res.data;
+                  }
+                  else {
+                    Alertify.alert(
+                      gettext('Error fetching tables to be attached'), res.data.result
+                    );
+                  }
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error, gettext('Error fetching tables to be attached'));
                 });
               }
             },
@@ -1148,12 +1148,12 @@ function(
             async: false,
             url: full_url,
             data: arg,
-            success: function(res) {
-              data = cache_node.cache(url, node_info, cache_level, res.data);
-            },
-            error: function() {
-              m.trigger('pgadmin:view:fetch:error', m, self.field);
-            },
+          })
+          .done(function(res) {
+            data = cache_node.cache(url, node_info, cache_level, res.data);
+          })
+          .fail(function() {
+            m.trigger('pgadmin:view:fetch:error', m, self.field);
           });
           m.trigger('pgadmin:view:fetched', m, self.field);
           data = (data && data.data) || [];
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
index 1f9bcf97..530cd118 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
@@ -164,25 +164,25 @@ define('pgadmin.node.table', [
                   type:'PUT',
                   data: params,
                   dataType: 'json',
-                  success: function(res) {
-                    if (res.success == 1) {
-                      Alertify.success(res.info);
-                      t.removeIcon(i);
-                      data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
-                      t.addIcon(i, {icon: data.icon});
-                      t.unload(i);
-                      t.setInode(i);
-                      t.deselect(i);
-                      // Fetch updated data from server
-                      setTimeout(function() {
-                        t.select(i);
-                      }, 10);
-                    }
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error);
+                })
+                .done(function(res) {
+                  if (res.success == 1) {
+                    Alertify.success(res.info);
+                    t.removeIcon(i);
+                    data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
+                    t.addIcon(i, {icon: data.icon});
                     t.unload(i);
-                  },
+                    t.setInode(i);
+                    t.deselect(i);
+                    // Fetch updated data from server
+                    setTimeout(function() {
+                      t.select(i);
+                    }, 10);
+                  }
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error);
+                  t.unload(i);
                 });
               }
             }, function() {}
@@ -207,25 +207,25 @@ define('pgadmin.node.table', [
                 $.ajax({
                   url: obj.generate_url(i, 'reset' , d, true),
                   type:'DELETE',
-                  success: function(res) {
-                    if (res.success == 1) {
-                      Alertify.success(res.info);
-                      t.removeIcon(i);
-                      data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
-                      t.addIcon(i, {icon: data.icon});
-                      t.unload(i);
-                      t.setInode(i);
-                      t.deselect(i);
-                      // Fetch updated data from server
-                      setTimeout(function() {
-                        t.select(i);
-                      }, 10);
-                    }
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error);
+                })
+                .done(function(res) {
+                  if (res.success == 1) {
+                    Alertify.success(res.info);
+                    t.removeIcon(i);
+                    data.icon = data.is_partitioned ? 'icon-partition': 'icon-table';
+                    t.addIcon(i, {icon: data.icon});
                     t.unload(i);
-                  },
+                    t.setInode(i);
+                    t.deselect(i);
+                    // Fetch updated data from server
+                    setTimeout(function() {
+                      t.select(i);
+                    }, 10);
+                  }
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error);
+                  t.unload(i);
                 });
               }
             },
@@ -245,20 +245,20 @@ define('pgadmin.node.table', [
           $.ajax({
             url: obj.generate_url(i, 'count_rows' , d, true),
             type:'GET',
-            success: function(res) {
-              Alertify.success(res.info);
-              d.rows_cnt = res.data.total_rows;
-              t.unload(i);
-              t.setInode(i);
-              t.deselect(i);
-              setTimeout(function() {
-                t.select(i);
-              }, 10);
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
-              t.unload(i);
-            },
+          })
+          .done(function(res) {
+            Alertify.success(res.info);
+            d.rows_cnt = res.data.total_rows;
+            t.unload(i);
+            t.setInode(i);
+            t.deselect(i);
+            setTimeout(function() {
+              t.select(i);
+            }, 10);
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
+            t.unload(i);
           });
         },
       },
@@ -983,19 +983,19 @@ define('pgadmin.node.table', [
 
                   type: 'GET',
                   async: false,
-                  success: function(res) {
-                    if (res.success == 1) {
-                      self.model.table_options = res.data;
-                    }
-                    else {
-                      Alertify.alert(
-                        gettext('Error fetching tables to be attached'), res.data.result
-                      );
-                    }
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error);
-                  },
+                })
+                .done(function(res) {
+                  if (res.success == 1) {
+                    self.model.table_options = res.data;
+                  }
+                  else {
+                    Alertify.alert(
+                      gettext('Error fetching tables to be attached'), res.data.result
+                    );
+                  }
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error);
                 });
               }
             },
@@ -1261,12 +1261,12 @@ define('pgadmin.node.table', [
             async: false,
             url: full_url,
             data: arg,
-            success: function(res) {
-              data = cache_node.cache(url, node_info, cache_level, res.data);
-            },
-            error: function() {
-              m.trigger('pgadmin:view:fetch:error', m, self.field);
-            },
+          })
+          .done(function(res) {
+            data = cache_node.cache(url, node_info, cache_level, res.data);
+          })
+          .fail(function() {
+            m.trigger('pgadmin:view:fetch:error', m, self.field);
           });
           m.trigger('pgadmin:view:fetched', m, self.field);
           data = (data && data.data) || [];
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
index a6e79ce2..85aab40b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.js
@@ -118,25 +118,25 @@ define('pgadmin.node.trigger', [
             type:'PUT',
             data: {'enable' : true},
             dataType: 'json',
-            success: function(res) {
-              if (res.success == 1) {
-                alertify.success(res.info);
-                t.removeIcon(i);
-                data.icon = 'icon-trigger';
-                t.addIcon(i, {icon: data.icon});
-                t.unload(i);
-                t.setInode(false);
-                t.deselect(i);
-                // Fetch updated data from server
-                setTimeout(function() {
-                  t.select(i);
-                }, 10);
-              }
-            },
-            error: function(xhr, status, error) {
-              alertify.pgRespErrorNotify(xhr, error);
+          })
+          .done(function(res) {
+            if (res.success == 1) {
+              alertify.success(res.info);
+              t.removeIcon(i);
+              data.icon = 'icon-trigger';
+              t.addIcon(i, {icon: data.icon});
               t.unload(i);
-            },
+              t.setInode(false);
+              t.deselect(i);
+              // Fetch updated data from server
+              setTimeout(function() {
+                t.select(i);
+              }, 10);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            alertify.pgRespErrorNotify(xhr, error);
+            t.unload(i);
           });
         },
         /* Disable trigger */
@@ -156,25 +156,25 @@ define('pgadmin.node.trigger', [
             type:'PUT',
             data: {'enable' : false},
             dataType: 'json',
-            success: function(res) {
-              if (res.success == 1) {
-                alertify.success(res.info);
-                t.removeIcon(i);
-                data.icon = 'icon-trigger-bad';
-                t.addIcon(i, {icon: data.icon});
-                t.unload(i);
-                t.setInode(false);
-                t.deselect(i);
-                // Fetch updated data from server
-                setTimeout(function() {
-                  t.select(i);
-                }, 10);
-              }
-            },
-            error: function(xhr, status, error) {
-              alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
+          })
+          .done(function(res) {
+            if (res.success == 1) {
+              alertify.success(res.info);
+              t.removeIcon(i);
+              data.icon = 'icon-trigger-bad';
+              t.addIcon(i, {icon: data.icon});
               t.unload(i);
-            },
+              t.setInode(false);
+              t.deselect(i);
+              // Fetch updated data from server
+              setTimeout(function() {
+                t.select(i);
+              }, 10);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            alertify.pgRespErrorNotify(xhr, error, gettext('Disable trigger failed'));
+            t.unload(i);
           });
         },
       },
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js
index 5860a752..12045cf1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.js
@@ -423,12 +423,12 @@ define('pgadmin.node.type', [
                   url: _url,
                   cache: false,
                   data: {'typname' : l_typname},
-                  success: function(res) {
-                    result = res.data;
-                  },
-                  error: function() {
-                    self.model.trigger('pgadmin:view:fetch:error', self.model, self.field);
-                  },
+                })
+                .done(function(res) {
+                  result = res.data;
+                })
+                .fail(function() {
+                  self.model.trigger('pgadmin:view:fetch:error', self.model, self.field);
                 });
                 //
               }
@@ -491,13 +491,13 @@ define('pgadmin.node.type', [
                   url: _url,
                   cache: false,
                   data: {'name' : name},
-                  success: function(res) {
-                    result = res.data;
-                  },
-                  error: function() {
-                    self.model.trigger('pgadmin:view:fetch:error',
-                      self.model, self.field);
-                  },
+                })
+                .done(function(res) {
+                  result = res.data;
+                })
+                .fail(function() {
+                  self.model.trigger('pgadmin:view:fetch:error',
+                    self.model, self.field);
                 });
               }
               return result;
@@ -527,13 +527,13 @@ define('pgadmin.node.type', [
                   url: _url,
                   cache: false,
                   data: {'typname' : l_typname, 'opcname': l_opcname},
-                  success: function(res) {
-                    result = res.data;
-                  },
-                  error: function() {
-                    self.model.trigger('pgadmin:view:fetch:error',
-                        self.model, self.field);
-                  },
+                })
+                .done(function(res) {
+                  result = res.data;
+                })
+                .fail(function() {
+                  self.model.trigger('pgadmin:view:fetch:error',
+                      self.model, self.field);
                 });
               }
               return result;
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js
index dcfdd54b..cda9636d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.js
@@ -253,20 +253,20 @@ define('pgadmin.node.mview', [
           type: 'PUT',
           data: {'concurrent': args.concurrent, 'with_data': args.with_data},
           dataType: 'json',
-          success: function(res) {
-            if (res.success == 1) {
-              Alertify.success(gettext('View refreshed successfully'));
-            }
-            else {
-              Alertify.alert(
-                gettext('Error refreshing view'),
-                  res.data.result
-              );
-            }
-          },
-          error: function(xhr, status, error) {
-            Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view'));
-          },
+        })
+        .done(function(res) {
+          if (res.success == 1) {
+            Alertify.success(gettext('View refreshed successfully'));
+          }
+          else {
+            Alertify.alert(
+              gettext('Error refreshing view'),
+                res.data.result
+            );
+          }
+        })
+        .fail(function(xhr, status, error) {
+          Alertify.pgRespErrorNotify(xhr, error, gettext('Error refreshing view'));
         });
 
       },
diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
index 1bb67598..d3902717 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
@@ -185,33 +185,33 @@ define('pgadmin.node.database', [
               $.ajax({
                 url: obj.generate_url(i, 'connect', d, true),
                 type:'DELETE',
-                success: function(res) {
-                  if (res.success == 1) {
-                    var prv_i = t.parent(i);
-                    Alertify.success(res.info);
-                    t.removeIcon(i);
-                    data.connected = false;
-                    data.icon = 'icon-database-not-connected';
-                    t.addIcon(i, {icon: data.icon});
-                    t.unload(i);
-                    t.setInode(i);
-                    setTimeout(function() {
-                      t.select(prv_i);
-                    }, 10);
-
-                  } else {
-                    try {
-                      Alertify.error(res.errormsg);
-                    } catch (e) {
-                      console.warn(e.stack || e);
-                    }
-                    t.unload(i);
+              })
+              .done(function(res) {
+                if (res.success == 1) {
+                  var prv_i = t.parent(i);
+                  Alertify.success(res.info);
+                  t.removeIcon(i);
+                  data.connected = false;
+                  data.icon = 'icon-database-not-connected';
+                  t.addIcon(i, {icon: data.icon});
+                  t.unload(i);
+                  t.setInode(i);
+                  setTimeout(function() {
+                    t.select(prv_i);
+                  }, 10);
+
+                } else {
+                  try {
+                    Alertify.error(res.errormsg);
+                  } catch (e) {
+                    console.warn(e.stack || e);
                   }
-                },
-                error: function(xhr, status, error) {
-                  Alertify.pgRespErrorNotify(xhr, error);
                   t.unload(i);
-                },
+                }
+              })
+              .fail(function(xhr, status, error) {
+                Alertify.pgRespErrorNotify(xhr, error);
+                t.unload(i);
               });
             },
             function() { return true; });
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js b/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js
index 74c99a40..44a6b5c1 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.js
@@ -172,13 +172,13 @@ define('pgadmin.node.pga_job', [
         $.ajax({
           url: obj.generate_url(i, 'run_now', d, true),
           method:'PUT',
-          // 'pgagent.pga_job' table updated with current time to run the job
-          // now.
-          success: function() { t.unload(i); },
-          error: function(xhr, status, error) {
-            alertify.pgRespErrorNotify(xhr, error);
-            t.unload(i);
-          },
+        })
+        // 'pgagent.pga_job' table updated with current time to run the job
+        // now.
+        .done(function() { t.unload(i); })
+        .fail(function(xhr, status, error) {
+          alertify.pgRespErrorNotify(xhr, error);
+          t.unload(i);
         });
 
         return false;
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js
index 9e0b6279..86247b53 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/server.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js
@@ -189,38 +189,38 @@ define('pgadmin.node.server', [
             $.ajax({
               url: obj.generate_url(i, 'connect', d, true),
               type:'DELETE',
-              success: function(res) {
-                if (res.success == 1) {
-                  Alertify.success(res.info);
-                  d = t.itemData(i);
-                  t.removeIcon(i);
-                  d.connected = false;
-                  d.icon = 'icon-server-not-connected';
-                  t.addIcon(i, {icon: d.icon});
-                  obj.callbacks.refresh.apply(obj, [null, i]);
-                  if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) {
-                    delete pgBrowser.serverInfo[d._id];
-                  }
-                  pgBrowser.enable_disable_menus(i);
-                  // Trigger server disconnect event
-                  pgBrowser.Events.trigger(
-                    'pgadmin:server:disconnect',
-                    {item: i, data: d}, false
-                  );
+            })
+            .done(function(res) {
+              if (res.success == 1) {
+                Alertify.success(res.info);
+                d = t.itemData(i);
+                t.removeIcon(i);
+                d.connected = false;
+                d.icon = 'icon-server-not-connected';
+                t.addIcon(i, {icon: d.icon});
+                obj.callbacks.refresh.apply(obj, [null, i]);
+                if (pgBrowser.serverInfo && d._id in pgBrowser.serverInfo) {
+                  delete pgBrowser.serverInfo[d._id];
                 }
-                else {
-                  try {
-                    Alertify.error(res.errormsg);
-                  } catch (e) {
-                    console.warn(e.stack || e);
-                  }
-                  t.unload(i);
+                pgBrowser.enable_disable_menus(i);
+                // Trigger server disconnect event
+                pgBrowser.Events.trigger(
+                  'pgadmin:server:disconnect',
+                  {item: i, data: d}, false
+                );
+              }
+              else {
+                try {
+                  Alertify.error(res.errormsg);
+                } catch (e) {
+                  console.warn(e.stack || e);
                 }
-              },
-              error: function(xhr, status, error) {
-                Alertify.pgRespErrorNotify(xhr, error);
                 t.unload(i);
-              },
+              }
+            })
+            .fail(function(xhr, status, error) {
+              Alertify.pgRespErrorNotify(xhr, error);
+              t.unload(i);
             });
           };
 
@@ -284,18 +284,18 @@ define('pgadmin.node.server', [
               $.ajax({
                 url: obj.generate_url(i, 'reload', d, true),
                 method:'GET',
-                success: function(res) {
-                  if (res.data.status) {
-                    Alertify.success(res.data.result);
-                  }
-                  else {
-                    Alertify.error(res.data.result);
-                  }
-                },
-                error: function(xhr, status, error) {
-                  Alertify.pgRespErrorNotify(xhr, error);
-                  t.unload(i);
-                },
+              })
+              .done(function(res) {
+                if (res.data.status) {
+                  Alertify.success(res.data.result);
+                }
+                else {
+                  Alertify.error(res.data.result);
+                }
+              })
+              .fail(function(xhr, status, error) {
+                Alertify.pgRespErrorNotify(xhr, error);
+                t.unload(i);
               });
             },
             function() { return true; }
@@ -325,13 +325,13 @@ define('pgadmin.node.server', [
                   url: obj.generate_url(i, 'restore_point', d, true),
                   method:'POST',
                   data:{ 'value': JSON.stringify(value) },
-                  success: function(res) {
-                    Alertify.success(res.data.result, 10);
-                  },
-                  error: function(xhr, status, error) {
-                    Alertify.pgRespErrorNotify(xhr, error);
-                    t.unload(i);
-                  },
+                })
+                .done(function(res) {
+                  Alertify.success(res.data.result, 10);
+                })
+                .fail(function(xhr, status, error) {
+                  Alertify.pgRespErrorNotify(xhr, error);
+                  t.unload(i);
                 });
               } else {
                 evt.cancel = true;
@@ -481,27 +481,27 @@ define('pgadmin.node.server', [
                       url: url,
                       method:'POST',
                       data:{'data': JSON.stringify(args) },
-                      success: function(res) {
-                        if (res.success) {
-                          // Notify user to update pgpass file
-                          if(is_pgpass_file_used) {
-                            Alertify.alert(
-                              gettext('Change Password'),
-                              gettext('Please make sure to disconnect the server'
-                                + ' and update the new password in the pgpass file'
-                                  + ' before performing any other operation')
-                            );
-                          }
-
-                          Alertify.success(res.info);
-                          self.close();
-                        } else {
-                          Alertify.error(res.errormsg);
+                    })
+                    .done(function(res) {
+                      if (res.success) {
+                        // Notify user to update pgpass file
+                        if(is_pgpass_file_used) {
+                          Alertify.alert(
+                            gettext('Change Password'),
+                            gettext('Please make sure to disconnect the server'
+                              + ' and update the new password in the pgpass file'
+                                + ' before performing any other operation')
+                          );
                         }
-                      },
-                      error: function(xhr, status, error) {
-                        Alertify.pgRespErrorNotify(xhr, error);
-                      },
+
+                        Alertify.success(res.info);
+                        self.close();
+                      } else {
+                        Alertify.error(res.errormsg);
+                      }
+                    })
+                    .fail(function(xhr, status, error) {
+                      Alertify.pgRespErrorNotify(xhr, error);
                     });
                   }
                 },
@@ -513,15 +513,15 @@ define('pgadmin.node.server', [
           $.ajax({
             url: check_pgpass_url,
             method:'GET',
-            success: function(res) {
-              if (res.success && res.data.is_pgpass) {
-                is_pgpass_file_used = true;
-              }
-              Alertify.changeServerPassword(d).resizeTo('40%','52%');
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
-            },
+          })
+          .done(function(res) {
+            if (res.success && res.data.is_pgpass) {
+              is_pgpass_file_used = true;
+            }
+            Alertify.changeServerPassword(d).resizeTo('40%','52%');
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
           });
 
           return false;
@@ -542,23 +542,23 @@ define('pgadmin.node.server', [
             url: obj.generate_url(i, 'wal_replay' , d, true),
             type:'DELETE',
             dataType: 'json',
-            success: function(res) {
-              if (res.success == 1) {
-                Alertify.success(res.info);
-                t.itemData(i).wal_pause=res.data.wal_pause;
-                t.unload(i);
-                t.setInode(i);
-                t.deselect(i);
-                // Fetch updated data from server
-                setTimeout(function() {
-                  t.select(i);
-                }, 10);
-              }
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
+          })
+          .done(function(res) {
+            if (res.success == 1) {
+              Alertify.success(res.info);
+              t.itemData(i).wal_pause=res.data.wal_pause;
               t.unload(i);
-            },
+              t.setInode(i);
+              t.deselect(i);
+              // Fetch updated data from server
+              setTimeout(function() {
+                t.select(i);
+              }, 10);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
+            t.unload(i);
           });
         },
 
@@ -577,23 +577,23 @@ define('pgadmin.node.server', [
             url: obj.generate_url(i, 'wal_replay' , d, true),
             type:'PUT',
             dataType: 'json',
-            success: function(res) {
-              if (res.success == 1) {
-                Alertify.success(res.info);
-                t.itemData(i).wal_pause=res.data.wal_pause;
-                t.unload(i);
-                t.setInode(i);
-                t.deselect(i);
-                // Fetch updated data from server
-                setTimeout(function() {
-                  t.select(i);
-                }, 10);
-              }
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
+          })
+          .done(function(res) {
+            if (res.success == 1) {
+              Alertify.success(res.info);
+              t.itemData(i).wal_pause=res.data.wal_pause;
               t.unload(i);
-            },
+              t.setInode(i);
+              t.deselect(i);
+              // Fetch updated data from server
+              setTimeout(function() {
+                t.select(i);
+              }, 10);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
+            t.unload(i);
           });
         },
       },
@@ -1128,16 +1128,16 @@ define('pgadmin.node.server', [
                   timeout: 30000,
                   url: _url,
                   data: $('#frmPassword').serialize(),
-                  success: function(res) {
-                    return _onSuccess(
-                      res, _node, _data, _tree, _item, _status
-                    );
-                  },
-                  error: function(xhr, status, error) {
-                    return _onFailure(
-                      xhr, status, error, _node, _data, _tree, _item, _status
-                    );
-                  },
+                })
+                .done(function(res) {
+                  return _onSuccess(
+                    res, _node, _data, _tree, _item, _status
+                  );
+                })
+                .fail(function(xhr, status, error) {
+                  return _onFailure(
+                    xhr, status, error, _node, _data, _tree, _item, _status
+                  );
                 });
               } else {
                 _onCancel && typeof(_onCancel) == 'function' &&
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 9e48b4f9..987c3bab 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -303,12 +303,12 @@ define([
             $.ajax({
               async: false,
               url: full_url,
-              success: function (res) {
-                data = res.data;
-              },
-              error: function() {
-                m.trigger('pgadmin-view:fetch:error', m, self.field);
-              },
+            })
+            .done(function (res) {
+              data = res.data;
+            })
+            .fail(function() {
+              m.trigger('pgadmin-view:fetch:error', m, self.field);
             });
             m.trigger('pgadmin-view:fetched', m, self.field);
 
diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js
index d8371aa0..90e97f0a 100644
--- a/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js
+++ b/web/pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.js
@@ -277,17 +277,17 @@ define('pgadmin.node.tablespace', [
                           url: url,
                           method:'PUT',
                           data:{'data': JSON.stringify(args) },
-                          success: function(res) {
-                            if (res.success) {
-                              Alertify.success(res.info);
-                              self.close();
-                            } else {
-                              Alertify.error(res.errormsg);
-                            }
-                          },
-                          error: function(xhr, status, error) {
-                            Alertify.pgRespErrorNotify(xhr, error);
-                          },
+                        })
+                        .done(function(res) {
+                          if (res.success) {
+                            Alertify.success(res.info);
+                            self.close();
+                          } else {
+                            Alertify.error(res.errormsg);
+                          }
+                        })
+                        .fail(function(xhr, status, error) {
+                          Alertify.pgRespErrorNotify(xhr, error);
                         });
                       },
                       function() {
diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js
index f8a56938..decbd98d 100644
--- a/web/pgadmin/browser/static/js/browser.js
+++ b/web/pgadmin/browser/static/js/browser.js
@@ -503,9 +503,9 @@ define('pgadmin.browser', [
         $.ajax({
           url: url_for('misc.cleanup'),
           type:'POST',
-          success: function() {},
-          error: function() {},
-        });
+        })
+        .done(function() {})
+        .fail(function() {});
       }, 300000);
       obj.Events.on('pgadmin:browser:tree:add', obj.onAddTreeNode, obj);
       obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj);
@@ -1539,69 +1539,69 @@ define('pgadmin.browser', [
           type: 'GET',
           cache: false,
           dataType: 'json',
-          success: function(res) {
-            // Node information can come as result/data
-            var data = res.result || res.data;
-
-            data._label = data.label;
-            data.label = _.escape(data.label);
-            var d = ctx.t.itemData(ctx.i);
-            _.extend(d, data);
-            ctx.t.setLabel(ctx.i, {label: _d.label});
-            ctx.t.addIcon(ctx.i, {icon: _d.icon});
-            ctx.t.setId(ctx.i, {id: _d.id});
-            ctx.t.setInode(ctx.i, {inode: data.inode});
+        })
+        .done(function(res) {
+          // Node information can come as result/data
+          var data = res.result || res.data;
+
+          data._label = data.label;
+          data.label = _.escape(data.label);
+          var d = ctx.t.itemData(ctx.i);
+          _.extend(d, data);
+          ctx.t.setLabel(ctx.i, {label: _d.label});
+          ctx.t.addIcon(ctx.i, {icon: _d.icon});
+          ctx.t.setId(ctx.i, {id: _d.id});
+          ctx.t.setInode(ctx.i, {inode: data.inode});
 
-            if (
-              _n.can_expand && typeof(_n.can_expand) == 'function'
-            ) {
-              if (!_n.can_expand(d)) {
-                ctx.t.unload(ctx.i);
-                return;
-              }
-            }
-            ctx.b._refreshNode(ctx, ctx.branch);
-            var success = (ctx.o && ctx.o.success) || ctx.success;
-            if (success && typeof(success) == 'function') {
-              success();
+          if (
+            _n.can_expand && typeof(_n.can_expand) == 'function'
+          ) {
+            if (!_n.can_expand(d)) {
+              ctx.t.unload(ctx.i);
+              return;
             }
-          },
-          error: function(xhr, error, status) {
-            if (
-              !Alertify.pgHandleItemError(
-                xhr, error, status, {item: _i, info: info}
-              )
-            ) {
-              var contentType = xhr.getResponseHeader('Content-Type'),
-                jsonResp = (
-                  contentType &&
-                    contentType.indexOf('application/json') == 0 &&
-                    JSON.parse(xhr.responseText)
-                ) || {};
+          }
+          ctx.b._refreshNode(ctx, ctx.branch);
+          var success = (ctx.o && ctx.o.success) || ctx.success;
+          if (success && typeof(success) == 'function') {
+            success();
+          }
+        })
+        .fail(function(xhr, error, status) {
+          if (
+            !Alertify.pgHandleItemError(
+              xhr, error, status, {item: _i, info: info}
+            )
+          ) {
+            var contentType = xhr.getResponseHeader('Content-Type'),
+              jsonResp = (
+                contentType &&
+                  contentType.indexOf('application/json') == 0 &&
+                  JSON.parse(xhr.responseText)
+              ) || {};
 
-              if (xhr.status == 410 && jsonResp.success == 0) {
-                var p = ctx.t.parent(ctx.i);
+            if (xhr.status == 410 && jsonResp.success == 0) {
+              var p = ctx.t.parent(ctx.i);
 
-                ctx.t.remove(ctx.i, {
-                  success: function() {
-                    if (p) {
-                      // Try to refresh the parent on error
-                      try {
-                        pgBrowser.Events.trigger(
-                          'pgadmin:browser:tree:refresh', p
-                        );
-                      } catch (e) { console.warn(e.stack || e); }
-                    }
-                  },
-                });
-              }
-
-              Alertify.pgNotifier(
-                error, xhr, gettext('Error retrieving details for the node.'),
-                function() { console.warn(arguments); }
-              );
+              ctx.t.remove(ctx.i, {
+                success: function() {
+                  if (p) {
+                    // Try to refresh the parent on error
+                    try {
+                      pgBrowser.Events.trigger(
+                        'pgadmin:browser:tree:refresh', p
+                      );
+                    } catch (e) { console.warn(e.stack || e); }
+                  }
+                },
+              });
             }
-          },
+
+            Alertify.pgNotifier(
+              error, xhr, gettext('Error retrieving details for the node.'),
+              function() { console.warn(arguments); }
+            );
+          }
         });
       }.bind(this);
 
@@ -1786,16 +1786,16 @@ define('pgadmin.browser', [
           $.ajax({
             url: childNodeUrl,
             dataType: 'json',
-            success: function(res) {
-              if (res.success) {
-                arrayChildNodeData.push(res.data);
-              }
-              fetchNodeInfo(_callback);
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
-              fetchNodeInfo(_callback);
-            },
+          })
+          .done(function(res) {
+            if (res.success) {
+              arrayChildNodeData.push(res.data);
+            }
+            fetchNodeInfo(_callback);
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
+            fetchNodeInfo(_callback);
           });
         };
 
diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js
index 35eca24b..bef03ae5 100644
--- a/web/pgadmin/browser/static/js/node.js
+++ b/web/pgadmin/browser/static/js/node.js
@@ -729,30 +729,30 @@ define('pgadmin.browser.node', [
             $.ajax({
               url: obj.generate_url(i, input.url, d, true),
               type: 'DELETE',
-              success: function(res) {
-                if (res.success == 0) {
-                  pgBrowser.report_error(res.errormsg, res.info);
-                } else {
-                  pgBrowser.removeTreeNode(i, true);
-                }
-                return true;
-              },
-              error: function(jqx) {
-                var msg = jqx.responseText;
-                /* Error from the server */
-                if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
-                  try {
-                    var data = JSON.parse(jqx.responseText);
-                    msg = data.errormsg;
-                  } catch (e) {
-                    console.warn(e.stack || e);
-                  }
+            })
+            .done(function(res) {
+              if (res.success == 0) {
+                pgBrowser.report_error(res.errormsg, res.info);
+              } else {
+                pgBrowser.removeTreeNode(i, true);
+              }
+              return true;
+            })
+            .fail(function(jqx) {
+              var msg = jqx.responseText;
+              /* Error from the server */
+              if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) {
+                try {
+                  var data = JSON.parse(jqx.responseText);
+                  msg = data.errormsg;
+                } catch (e) {
+                  console.warn(e.stack || e);
                 }
-                pgBrowser.report_error(
-                  S(gettext('Error dropping %s: "%s"'))
-                  .sprintf(obj.label, objName)
-                  .value(), msg);
-              },
+              }
+              pgBrowser.report_error(
+                S(gettext('Error dropping %s: "%s"'))
+                .sprintf(obj.label, objName)
+                .value(), msg);
             });
           },
           null).show();
diff --git a/web/pgadmin/browser/static/js/node.ui.js b/web/pgadmin/browser/static/js/node.ui.js
index 227b4571..064ca312 100644
--- a/web/pgadmin/browser/static/js/node.ui.js
+++ b/web/pgadmin/browser/static/js/node.ui.js
@@ -146,16 +146,16 @@ define([
             $.ajax({
               async: false,
               url: full_url,
-              success: function(res) {
-                /*
-                 * We will cache this data for short period of time for avoiding
-                 * same calls.
-                 */
-                data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
-              },
-              error: function() {
-                m.trigger('pgadmin:view:fetch:error', m, self.field);
-              },
+            })
+            .done(function(res) {
+              /*
+               * We will cache this data for short period of time for avoiding
+               * same calls.
+               */
+              data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
+            })
+            .fail(function() {
+              m.trigger('pgadmin:view:fetch:error', m, self.field);
             });
             m.trigger('pgadmin:view:fetched', m, self.field);
           }
@@ -387,16 +387,16 @@ define([
           $.ajax({
             async: false,
             url: full_url,
-            success: function(res) {
-              /*
-               * We will cache this data for short period of time for avoiding
-               * same calls.
-               */
-              data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
-            },
-            error: function() {
-              eventHandler.trigger('pgadmin:view:fetch:error', m, column);
-            },
+          })
+          .done(function(res) {
+            /*
+             * We will cache this data for short period of time for avoiding
+             * same calls.
+             */
+            data = cache_node.cache(node.type + '#' + url, node_info, cache_level, res.data);
+          })
+          .fail(function() {
+            eventHandler.trigger('pgadmin:view:fetch:error', m, column);
           });
           eventHandler.trigger('pgadmin:view:fetched', m, column);
         }
@@ -559,4 +559,4 @@ define([
   });
 
   return Backform;
-});
\ No newline at end of file
+});
diff --git a/web/pgadmin/browser/static/js/preferences.js b/web/pgadmin/browser/static/js/preferences.js
index b0c6dc48..1e84bd41 100644
--- a/web/pgadmin/browser/static/js/preferences.js
+++ b/web/pgadmin/browser/static/js/preferences.js
@@ -80,32 +80,32 @@ _.extend(pgBrowser, {
     setTimeout(function() {
       $.ajax({
         url: url_for('preferences.get_all'),
-        success: function(res) {
-          self.preferences_cache = res;
-          self.preference_version(self.generate_preference_version());
-
-          pgBrowser.keyboardNavigation.init();
-          if(pgBrowser.tree) {
-            modifyAnimation.modifyAcitreeAnimation(self);
-            modifyAnimation.modifyAlertifyAnimation(self);
+      })
+      .done(function(res) {
+        self.preferences_cache = res;
+        self.preference_version(self.generate_preference_version());
+
+        pgBrowser.keyboardNavigation.init();
+        if(pgBrowser.tree) {
+          modifyAnimation.modifyAcitreeAnimation(self);
+          modifyAnimation.modifyAlertifyAnimation(self);
+        }
+
+        /* Once the cache is loaded after changing the preferences,
+         * notify the modules of the change
+         */
+        if(modulesChanged) {
+          if(typeof modulesChanged === 'string'){
+            $.event.trigger('prefchange:'+modulesChanged);
+          } else {
+            _.each(modulesChanged, (val, key)=> {
+              $.event.trigger('prefchange:'+key);
+            });
           }
-
-          /* Once the cache is loaded after changing the preferences,
-           * notify the modules of the change
-           */
-          if(modulesChanged) {
-            if(typeof modulesChanged === 'string'){
-              $.event.trigger('prefchange:'+modulesChanged);
-            } else {
-              _.each(modulesChanged, (val, key)=> {
-                $.event.trigger('prefchange:'+key);
-              });
-            }
-          }
-        },
-        error: function(xhr, status, error) {
-          Alertify.pgRespErrorNotify(xhr, error);
-        },
+        }
+      })
+      .fail(function(xhr, status, error) {
+        Alertify.pgRespErrorNotify(xhr, error);
       });
     }, 500);
   },
diff --git a/web/pgadmin/dashboard/static/js/dashboard.js b/web/pgadmin/dashboard/static/js/dashboard.js
index 5c812bf5..02c7d439 100644
--- a/web/pgadmin/dashboard/static/js/dashboard.js
+++ b/web/pgadmin/dashboard/static/js/dashboard.js
@@ -89,17 +89,17 @@ define('pgadmin.dashboard', [
           $.ajax({
             url: action_url,
             type: 'DELETE',
-            success: function(res) {
-              if (res == gettext('Success')) {
-                Alertify.success(txtSuccess);
-                refresh_grid();
-              } else {
-                Alertify.error(txtError);
-              }
-            },
-            error: function(xhr, status, error) {
-              Alertify.pgRespErrorNotify(xhr, error);
-            },
+          })
+          .done(function(res) {
+            if (res == gettext('Success')) {
+              Alertify.success(txtSuccess);
+              refresh_grid();
+            } else {
+              Alertify.error(txtError);
+            }
+          })
+          .fail(function(xhr, status, error) {
+            Alertify.pgRespErrorNotify(xhr, error);
           });
         },
         function() {
@@ -214,14 +214,14 @@ define('pgadmin.dashboard', [
             url: url,
             type: 'GET',
             dataType: 'html',
-            success: function(data) {
-              $(div).html(data);
-            },
-            error: function() {
-              $(div).html(
-                '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
-              );
-            },
+          })
+          .done(function(data) {
+            $(div).html(data);
+          })
+          .fail(function() {
+            $(div).html(
+              '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
+            );
           });
 
           // Cache the current IDs for next time
@@ -306,14 +306,14 @@ define('pgadmin.dashboard', [
                   url: url,
                   type: 'GET',
                   dataType: 'html',
-                  success: function(data) {
-                    $(div).html(data);
-                  },
-                  error: function() {
-                    $(div).html(
-                      '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
-                    );
-                  },
+                })
+                .done(function(data) {
+                  $(div).html(data);
+                })
+                .fail(function() {
+                  $(div).html(
+                    '<div class="alert alert-danger pg-panel-message" role="alert">' + gettext('An error occurred whilst loading the dashboard.') + '</div>'
+                  );
                 });
                 $(dashboardPanel).data('server_status', true);
               }
@@ -431,43 +431,43 @@ define('pgadmin.dashboard', [
           url: path,
           type: 'GET',
           dataType: 'html',
-          success: function(resp) {
-            $(container).removeClass('graph-error');
-            data = JSON.parse(resp);
-            pgAdmin.Dashboard.render_chart(container, data, dataset, sid, did, url, options, counter, refresh);
-          },
-          error: function(xhr) {
-            let err = '';
-            let msg = '';
-            let cls = 'info';
-
-            if (xhr.readyState === 0) {
-              msg = gettext('Not connected to the server or the connection to the server has been closed.');
-            } else {
-              err = JSON.parse(xhr.responseText);
-              msg = err.errormsg;
-
-              // If we get a 428, it means the server isn't connected
-              if (xhr.status === 428) {
-                if (_.isUndefined(msg) || _.isNull(msg)) {
-                  msg = gettext('Please connect to the selected server to view the graph.');
-                }
-              } else {
-                msg = gettext('An error occurred whilst rendering the graph.');
-                cls = 'danger';
+        })
+        .done(function(resp) {
+          $(container).removeClass('graph-error');
+          data = JSON.parse(resp);
+          pgAdmin.Dashboard.render_chart(container, data, dataset, sid, did, url, options, counter, refresh);
+        })
+        .fail(function(xhr) {
+          let err = '';
+          let msg = '';
+          let cls = 'info';
+
+          if (xhr.readyState === 0) {
+            msg = gettext('Not connected to the server or the connection to the server has been closed.');
+          } else {
+            err = JSON.parse(xhr.responseText);
+            msg = err.errormsg;
+
+            // If we get a 428, it means the server isn't connected
+            if (xhr.status === 428) {
+              if (_.isUndefined(msg) || _.isNull(msg)) {
+                msg = gettext('Please connect to the selected server to view the graph.');
               }
+            } else {
+              msg = gettext('An error occurred whilst rendering the graph.');
+              cls = 'danger';
             }
+          }
 
-            $(container).addClass('graph-error');
-            $(container).html(
-              '<div class="alert alert-' + cls + ' pg-panel-message" role="alert">' + msg + '</div>'
-            );
+          $(container).addClass('graph-error');
+          $(container).html(
+            '<div class="alert alert-' + cls + ' pg-panel-message" role="alert">' + msg + '</div>'
+          );
 
-            // Try again...
-            if (container.clientHeight > 0 && container.clientWidth > 0) {
-              setTimeout(setTimeoutFunc, refresh * 1000);
-            }
-          },
+          // Try again...
+          if (container.clientHeight > 0 && container.clientWidth > 0) {
+            setTimeout(setTimeoutFunc, refresh * 1000);
+          }
         });
       };
 
diff --git a/web/pgadmin/misc/bgprocess/static/js/bgprocess.js b/web/pgadmin/misc/bgprocess/static/js/bgprocess.js
index 0934ae40..986a5401 100644
--- a/web/pgadmin/misc/bgprocess/static/js/bgprocess.js
+++ b/web/pgadmin/misc/bgprocess/static/js/bgprocess.js
@@ -226,18 +226,18 @@ define('misc.bgprocess', [
           cache: false,
           async: true,
           contentType: 'application/json',
-          success: function(res) {
+        })
+        .done(function(res) {
+          setTimeout(function() {
+            self.update(res);
+          }, 10);
+        })
+        .fail(function(res) {
+          // Try after some time only if job id present
+          if (res.status != 410)
             setTimeout(function() {
               self.update(res);
-            }, 10);
-          },
-          error: function(res) {
-            // Try after some time only if job id present
-            if (res.status != 410)
-              setTimeout(function() {
-                self.update(res);
-              }, 10000);
-          },
+            }, 10000);
         });
       },
 
@@ -429,12 +429,12 @@ define('misc.bgprocess', [
           cache: false,
           async: true,
           contentType: 'application/json',
-          success: function() {
-            return;
-          },
-          error: function() {
-            console.warn(arguments);
-          },
+        })
+        .done(function() {
+          return;
+        })
+        .fail(function() {
+          console.warn(arguments);
         });
       },
     });
@@ -478,31 +478,31 @@ define('misc.bgprocess', [
           cache: false,
           async: true,
           contentType: 'application/json',
-          success: function(res) {
-            if (!res || !_.isArray(res)) {
-              return;
-            }
-            for (var idx in res) {
-              var process = res[idx];
-              if ('id' in process) {
-                if (!(process.id in observer.bgprocesses)) {
-                  observer.bgprocesses[process.id] = new BGProcess(process);
-                }
+        })
+        .done(function(res) {
+          if (!res || !_.isArray(res)) {
+            return;
+          }
+          for (var idx in res) {
+            var process = res[idx];
+            if ('id' in process) {
+              if (!(process.id in observer.bgprocesses)) {
+                observer.bgprocesses[process.id] = new BGProcess(process);
               }
             }
-            if (recheck && res.length == 0) {
-              // Recheck after some more time
-              setTimeout(
-                function() {
-                  observer.update_process_list(false);
-                }, 3000
-              );
-            }
-          },
-          error: function() {
-            // FIXME:: What to do now?
-            console.warn(arguments);
-          },
+          }
+          if (recheck && res.length == 0) {
+            // Recheck after some more time
+            setTimeout(
+              function() {
+                observer.update_process_list(false);
+              }, 3000
+            );
+          }
+        })
+        .fail(function() {
+          // FIXME:: What to do now?
+          console.warn(arguments);
         });
       },
 
diff --git a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js
index 8deb7200..c640473a 100644
--- a/web/pgadmin/misc/file_manager/static/js/create_dialogue.js
+++ b/web/pgadmin/misc/file_manager/static/js/create_dialogue.js
@@ -82,14 +82,14 @@ module.exports =  Alertify.dialog('createModeDlg', function() {
         dataType: 'json',
         contentType: 'application/x-download; charset=utf-8',
         async: false,
-        success: function(resp) {
-          var data = resp.data.result;
-          if (data['Code'] === 1) {
-            is_exist = true;
-          } else {
-            is_exist = false;
-          }
-        },
+      })
+      .done(function(resp) {
+        var data = resp.data.result;
+        if (data['Code'] === 1) {
+          is_exist = true;
+        } else {
+          is_exist = false;
+        }
       });
       return is_exist;
     },
@@ -109,19 +109,19 @@ module.exports =  Alertify.dialog('createModeDlg', function() {
         dataType: 'json',
         contentType: 'application/json; charset=utf-8',
         async: false,
-        success: function(resp) {
-          var data = resp.data.result;
-          if (data.Code === 1) {
-            permission = true;
-          } else {
-            $('.file_manager_ok').addClass('disabled');
-            Alertify.error(data.Error);
-          }
-        },
-        error: function() {
+      })
+      .done(function(resp) {
+        var data = resp.data.result;
+        if (data.Code === 1) {
+          permission = true;
+        } else {
           $('.file_manager_ok').addClass('disabled');
-          Alertify.error(gettext('Error occurred while checking access permission.'));
-        },
+          Alertify.error(data.Error);
+        }
+      })
+      .fail(function() {
+        $('.file_manager_ok').addClass('disabled');
+        Alertify.error(gettext('Error occurred while checking access permission.'));
       });
       return permission;
     },
diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js
index dc787e3f..14a5226a 100644
--- a/web/pgadmin/misc/file_manager/static/js/utility.js
+++ b/web/pgadmin/misc/file_manager/static/js/utility.js
@@ -242,40 +242,40 @@ define([
             dataType: 'json',
             contentType: 'application/json; charset=utf-8',
             async: false,
-            success: function(resp) {
-              var result = resp.data.result;
-              if (result.Code === 1) {
-                var newPath = result['New Path'],
-                  newName = result['New Name'],
-                  title = $('#preview h1').attr('title');
-
-                if (typeof title != 'undefined' && title == oldPath) {
-                  $('#preview h1').text(newName);
-                }
+          })
+          .done(function(resp) {
+            var result = resp.data.result;
+            if (result.Code === 1) {
+              var newPath = result['New Path'],
+                newName = result['New Name'],
+                title = $('#preview h1').attr('title');
+
+              if (typeof title != 'undefined' && title == oldPath) {
+                $('#preview h1').text(newName);
+              }
 
-                if ($('.fileinfo').data('view') == 'grid') {
-                  $('.fileinfo span[data-alt="' + oldPath + '"]').parent().next('p span').text(newName);
-                  $('.fileinfo span[data-alt="' + oldPath + '"]').attr('data-alt', newPath);
-                } else {
-                  $('.fileinfo td[title="' + oldPath + '"]').text(newName);
-                  $('.fileinfo td[title="' + oldPath + '"]').attr('title', newPath);
-                }
-                $('#preview h1').html(newName);
+              if ($('.fileinfo').data('view') == 'grid') {
+                $('.fileinfo span[data-alt="' + oldPath + '"]').parent().next('p span').text(newName);
+                $('.fileinfo span[data-alt="' + oldPath + '"]').attr('data-alt', newPath);
+              } else {
+                $('.fileinfo td[title="' + oldPath + '"]').text(newName);
+                $('.fileinfo td[title="' + oldPath + '"]').attr('title', newPath);
+              }
+              $('#preview h1').html(newName);
 
-                // actualized data for binding
-                data.Path = newPath;
-                data.Filename = newName;
+              // actualized data for binding
+              data.Path = newPath;
+              data.Filename = newName;
 
-                // UnBind toolbar functions.
-                $('.fileinfo').find('button.rename, button.delete, button.download').off();
+              // UnBind toolbar functions.
+              $('.fileinfo').find('button.rename, button.delete, button.download').off();
 
-                Alertify.success(lg.successful_rename);
-              } else {
-                Alertify.error(result.Error);
-              }
+              Alertify.success(lg.successful_rename);
+            } else {
+              Alertify.error(result.Error);
+            }
 
-              finalName = result['New Name'];
-            },
+            finalName = result['New Name'];
           });
         }
       };
@@ -305,21 +305,21 @@ define([
         dataType: 'json',
         contentType: 'application/json; charset=utf-8',
         async: false,
-        success: function(resp) {
-          var result = resp.data.result;
-          if (result.Code === 1) {
-            isDeleted = true;
-            if (isDeleted) {
-              Alertify.success(lg.successful_delete);
-              var rootpath = result.Path.substring(0, result.Path.length - 1); // removing the last slash
-              rootpath = rootpath.substr(0, rootpath.lastIndexOf('/') + 1);
-              getFolderInfo(rootpath);
-            }
-          } else {
-            isDeleted = false;
-            Alertify.error(result.Error);
+      })
+      .done(function(resp) {
+        var result = resp.data.result;
+        if (result.Code === 1) {
+          isDeleted = true;
+          if (isDeleted) {
+            Alertify.success(lg.successful_delete);
+            var rootpath = result.Path.substring(0, result.Path.length - 1); // removing the last slash
+            rootpath = rootpath.substr(0, rootpath.lastIndexOf('/') + 1);
+            getFolderInfo(rootpath);
           }
-        },
+        } else {
+          isDeleted = false;
+          Alertify.error(result.Error);
+        }
       });
       return isDeleted;
     };
@@ -356,34 +356,34 @@ define([
       dataType: 'json',
       contentType: 'application/json; charset=utf-8',
       async: false,
-      success: function(resp) {
-        var data = resp.data.result;
-        if (data.Code === 1) {
-          $('.file_manager_ok').removeClass('disabled');
-          $('.file_manager_ok').attr('disabled', false);
-          data.Capabilities = capabilities;
-          bindToolbar(data);
-          if (data.FileType == 'Directory') {
-            // Enable/Disable level up button
-            enab_dis_level_up();
-            $('.file_manager_ok').addClass('disabled');
-            $('.file_manager_ok').attr('disabled', true);
-            $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
-            $('.file_manager button.download').attr('disabled', 'disabled');
+    })
+    .done(function(resp) {
+      var data = resp.data.result;
+      if (data.Code === 1) {
+        $('.file_manager_ok').removeClass('disabled');
+        $('.file_manager_ok').attr('disabled', false);
+        data.Capabilities = capabilities;
+        bindToolbar(data);
+        if (data.FileType == 'Directory') {
+          // Enable/Disable level up button
+          enab_dis_level_up();
+          $('.file_manager_ok').addClass('disabled');
+          $('.file_manager_ok').attr('disabled', true);
+          $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
+          $('.file_manager button.download').attr('disabled', 'disabled');
 
-            if (file.charAt(file.length - 1) != '/' && file.charAt(file.length - 1) != '\\') {
-              file += '/';
-            }
-            getFolderInfo(file);
-          } else {
-            is_file_valid = true;
+          if (file.charAt(file.length - 1) != '/' && file.charAt(file.length - 1) != '\\') {
+            file += '/';
           }
+          getFolderInfo(file);
         } else {
-          $('.file_manager_ok').addClass('disabled');
-          $('.file_manager_ok').attr('disabled', true);
-          Alertify.error(data.Error);
+          is_file_valid = true;
         }
-      },
+      } else {
+        $('.file_manager_ok').addClass('disabled');
+        $('.file_manager_ok').attr('disabled', true);
+        Alertify.error(data.Error);
+      }
     });
     return is_file_valid;
   };
@@ -402,23 +402,23 @@ define([
       dataType: 'json',
       contentType: 'application/json; charset=utf-8',
       async: false,
-      success: function(resp) {
-        var data = resp.data.result;
-        if (data.Code === 1) {
-          permission = true;
-        } else {
-          $('.file_manager_ok').addClass('disabled');
-          $('.file_manager_ok').attr('disabled', true);
-          Alertify.error(data.Error);
-        }
-      },
-      error: function() {
+    })
+    .done(function(resp) {
+      var data = resp.data.result;
+      if (data.Code === 1) {
+        permission = true;
+      } else {
         $('.file_manager_ok').addClass('disabled');
         $('.file_manager_ok').attr('disabled', true);
-        Alertify.error(
-          gettext('Error occurred while checking access permission.')
-        );
-      },
+        Alertify.error(data.Error);
+      }
+    })
+    .fail(function() {
+      $('.file_manager_ok').addClass('disabled');
+      $('.file_manager_ok').attr('disabled', true);
+      Alertify.error(
+        gettext('Error occurred while checking access permission.')
+      );
     });
     return permission;
   };
@@ -488,515 +488,515 @@ define([
       dataType: 'json',
       contentType: 'application/json; charset=utf-8',
       async: false,
-      success: function(resp) {
-        $('.storage_dialog #uploader .input-path').prop('disabled', false);
-        var result = '',
-          data = resp.data.result;
-
-        // hide activity indicator
-        $('.fileinfo').find('span.activity').hide();
-        if (data.Code === 0) {
-          Alertify.error(data.Error);
-          return;
-        }
-
-        var $this, orig_value, newvalue;
-
-        // generate HTML for files/folder and render into container
-        if (!_.isEmpty(data)) {
-          if ($('.fileinfo').data('view') == 'grid') {
-            result += '<ul id="contents" class="grid">';
-            Object.keys(data).sort(function keyOrder(x, y) {
-              return pgAdmin.natural_sort(x.toLowerCase(), y.toLowerCase());
-            }).forEach(function(key) {
-              var props = (data[key]).Properties,
-                cap_classes = '';
-
-              Object.keys(capabilities).forEach(function(cap) {
-                if (has_capability(data[key], capabilities[cap])) {
-                  cap_classes += 'cap_' + capabilities[cap];
-                }
-              });
+    })
+    .done(function(resp) {
+      $('.storage_dialog #uploader .input-path').prop('disabled', false);
+      var result = '',
+        data = resp.data.result;
+
+      // hide activity indicator
+      $('.fileinfo').find('span.activity').hide();
+      if (data.Code === 0) {
+        Alertify.error(data.Error);
+        return;
+      }
 
-              (data[key]).Capabilities = capabilities;
-              bindToolbar(data[key]);
+      var $this, orig_value, newvalue;
 
-              var class_type;
-              if ((data[key]).file_type == 'dir') {
-                class_type = 'fa fa-folder-open fm_folder';
-              } else if ((data[key]).file_type == 'drive') {
-                class_type = 'fa fa-hdd-o fm_drive';
-              } else {
-                class_type = 'fa fa-file-text fm_file';
+      // generate HTML for files/folder and render into container
+      if (!_.isEmpty(data)) {
+        if ($('.fileinfo').data('view') == 'grid') {
+          result += '<ul id="contents" class="grid">';
+          Object.keys(data).sort(function keyOrder(x, y) {
+            return pgAdmin.natural_sort(x.toLowerCase(), y.toLowerCase());
+          }).forEach(function(key) {
+            var props = (data[key]).Properties,
+              cap_classes = '';
+
+            Object.keys(capabilities).forEach(function(cap) {
+              if (has_capability(data[key], capabilities[cap])) {
+                cap_classes += 'cap_' + capabilities[cap];
               }
+            });
 
-              var fm_filename = (data[key]).Filename;
-              if (fm_filename.length > 15) {
-                fm_filename = (data[key]).Filename.substr(0, 10) + '...';
-              }
-              fm_filename = _.escape(fm_filename);
+            (data[key]).Capabilities = capabilities;
+            bindToolbar(data[key]);
 
-              var file_path_orig = _.escape((data[key]).Path);
+            var class_type;
+            if ((data[key]).file_type == 'dir') {
+              class_type = 'fa fa-folder-open fm_folder';
+            } else if ((data[key]).file_type == 'drive') {
+              class_type = 'fa fa-hdd-o fm_drive';
+            } else {
+              class_type = 'fa fa-file-text fm_file';
+            }
 
-              result += '<li class="' + cap_classes +
-                '"><div class="clip"><span data-alt="' +
-                file_path_orig + '" class="' + class_type + '"></span>';
-              if ((data[key]).Protected == 1) {
-                result += '<span class="fa fa-lock fm_lock_icon" data-protected="protected"></span>';
-              }
+            var fm_filename = (data[key]).Filename;
+            if (fm_filename.length > 15) {
+              fm_filename = (data[key]).Filename.substr(0, 10) + '...';
+            }
+            fm_filename = _.escape(fm_filename);
 
-              result += '</div>';
-              if (!has_capability(data[key], 'rename')) {
-                result += '<span>' + fm_filename + '</span>';
-              } else {
-                result +=
-                  '<p><input type="text" class="fm_file_rename" />' +
-                  '<span class="less_text" title="' + fm_filename + '">' + fm_filename +
-                  '</span></p>';
-              }
-              if (props.Width && props.Width != '') {
-                result += '<span class="meta dimensions">' +
-                  props.Width + 'x' + props.Height + '</span>';
-              }
-              if (props.Size && props.Size != '') {
-                result += '<span class="meta size">' +
-                  props.Size + '</span>';
-              }
-              if (props['Date Created'] && props['Date Created'] != '') {
-                result += '<span class="meta created">' +
-                  props['Date Created'] + '</span>';
-              }
-              if (props['Date Modified'] && props['Date Modified'] != '') {
-                result += '<span class="meta modified">' +
-                  props['Date Modified'] + '</span>';
-              }
-              result += '</li>';
-            });
+            var file_path_orig = _.escape((data[key]).Path);
 
-            result += '</ul>';
-          } else {
-            result += '<table id="contents" class="list tablesorter">';
-            result += '<thead><tr><th>';
-            result += '<span>' + lg.name + '</span></th>';
-            result += '<th><span>' + lg.size + '</span></th><th>';
-            result += '<span>' + lg.modified + '</span></th></tr></thead>';
-            result += '<tbody>';
-
-            Object.keys(data).sort(function keyOrder(x, y) {
-              return pgAdmin.natural_sort(x.toLowerCase(), y.toLowerCase());
-            }).forEach(function(key) {
-              var path = _.escape((data[key]).Path),
-                props = (data[key]).Properties,
-                cap_classes = '',
-                cap, class_type;
-
-              for (cap in capabilities) {
-                if (has_capability(data[key], capabilities[cap])) {
-                  cap_classes += ' cap_' + capabilities[cap];
-                }
-              }
+            result += '<li class="' + cap_classes +
+              '"><div class="clip"><span data-alt="' +
+              file_path_orig + '" class="' + class_type + '"></span>';
+            if ((data[key]).Protected == 1) {
+              result += '<span class="fa fa-lock fm_lock_icon" data-protected="protected"></span>';
+            }
 
-              (data[key]).Capabilities = capabilities;
-              bindToolbar(data[key]);
+            result += '</div>';
+            if (!has_capability(data[key], 'rename')) {
+              result += '<span>' + fm_filename + '</span>';
+            } else {
+              result +=
+                '<p><input type="text" class="fm_file_rename" />' +
+                '<span class="less_text" title="' + fm_filename + '">' + fm_filename +
+                '</span></p>';
+            }
+            if (props.Width && props.Width != '') {
+              result += '<span class="meta dimensions">' +
+                props.Width + 'x' + props.Height + '</span>';
+            }
+            if (props.Size && props.Size != '') {
+              result += '<span class="meta size">' +
+                props.Size + '</span>';
+            }
+            if (props['Date Created'] && props['Date Created'] != '') {
+              result += '<span class="meta created">' +
+                props['Date Created'] + '</span>';
+            }
+            if (props['Date Modified'] && props['Date Modified'] != '') {
+              result += '<span class="meta modified">' +
+                props['Date Modified'] + '</span>';
+            }
+            result += '</li>';
+          });
 
-              if ((data[key]).file_type == 'dir') {
-                class_type = 'fa fa-folder-open tbl_folder';
-              } else if ((data[key]).file_type == 'drive') {
-                class_type = 'fa fa-hdd-o tbl_drive';
-              } else {
-                class_type = 'fa fa-file-text tbl_file';
+          result += '</ul>';
+        } else {
+          result += '<table id="contents" class="list tablesorter">';
+          result += '<thead><tr><th>';
+          result += '<span>' + lg.name + '</span></th>';
+          result += '<th><span>' + lg.size + '</span></th><th>';
+          result += '<span>' + lg.modified + '</span></th></tr></thead>';
+          result += '<tbody>';
+
+          Object.keys(data).sort(function keyOrder(x, y) {
+            return pgAdmin.natural_sort(x.toLowerCase(), y.toLowerCase());
+          }).forEach(function(key) {
+            var path = _.escape((data[key]).Path),
+              props = (data[key]).Properties,
+              cap_classes = '',
+              cap, class_type;
+
+            for (cap in capabilities) {
+              if (has_capability(data[key], capabilities[cap])) {
+                cap_classes += ' cap_' + capabilities[cap];
               }
+            }
 
-              result += '<tr class="' + cap_classes + '">';
+            (data[key]).Capabilities = capabilities;
+            bindToolbar(data[key]);
 
-              var fm_filename = (data[key]).Filename;
-              if (fm_filename.length > 48) {
-                fm_filename = (data[key]).Filename.substr(0, 48) + '...';
-              }
-              fm_filename = _.escape(fm_filename);
+            if ((data[key]).file_type == 'dir') {
+              class_type = 'fa fa-folder-open tbl_folder';
+            } else if ((data[key]).file_type == 'drive') {
+              class_type = 'fa fa-hdd-o tbl_drive';
+            } else {
+              class_type = 'fa fa-file-text tbl_file';
+            }
 
-              result += '<td title="' + path + '" class="' + class_type + '">';
-              if ((data[key]).Protected == 1) {
-                result +=
-                  '<i class="fa fa-lock tbl_lock_icon" data-protected="protected"></i>';
-              }
-              if (!has_capability(data[key], 'rename')) {
-                result += '<span title="' + (data[key]).Filename + '">' +
-                  fm_filename + '</span></td>';
-              } else {
-                result += '<p><input type="text" class="fm_file_rename"/><span class="less_text" title="' +
-                  fm_filename + '">' + fm_filename + '</span></p></td>';
-              }
-              if (props.Size && props.Size != '') {
-                result += '<td><span title="' + props.Size + '">' +
-                  props.Size + '</span></td>';
-              } else {
-                result += '<td></td>';
-              }
+            result += '<tr class="' + cap_classes + '">';
 
-              if (props['Date Modified'] && props['Date Modified'] != '') {
-                result += '<td>' + props['Date Modified'] + '</td>';
-              } else {
-                result += '<td></td>';
-              }
+            var fm_filename = (data[key]).Filename;
+            if (fm_filename.length > 48) {
+              fm_filename = (data[key]).Filename.substr(0, 48) + '...';
+            }
+            fm_filename = _.escape(fm_filename);
 
-              result += '</tr>';
-            });
+            result += '<td title="' + path + '" class="' + class_type + '">';
+            if ((data[key]).Protected == 1) {
+              result +=
+                '<i class="fa fa-lock tbl_lock_icon" data-protected="protected"></i>';
+            }
+            if (!has_capability(data[key], 'rename')) {
+              result += '<span title="' + (data[key]).Filename + '">' +
+                fm_filename + '</span></td>';
+            } else {
+              result += '<p><input type="text" class="fm_file_rename"/><span class="less_text" title="' +
+                fm_filename + '">' + fm_filename + '</span></p></td>';
+            }
+            if (props.Size && props.Size != '') {
+              result += '<td><span title="' + props.Size + '">' +
+                props.Size + '</span></td>';
+            } else {
+              result += '<td></td>';
+            }
 
-            result += '</tbody>';
-            result += '</table>';
-          }
-        } else {
-          if ($('.fileinfo').data('view') == 'grid') {
-            result += '<ul id="contents" class="grid"></ul>';
-          } else {
-            result += '<table id="contents" class="list tablesorter">';
-            result += '<thead><tr><th><span>' +
-              lg.name + '</span></th><th><span>' + lg.size +
-              '</span></th><th><span>' + lg.modified +
-              '</span></th></tr></thead>';
-            result += '<tbody>';
-          }
-          result += '<h1 class="no_folder_found">' +
-            lg.could_not_retrieve_folder + '</h1>';
+            if (props['Date Modified'] && props['Date Modified'] != '') {
+              result += '<td>' + props['Date Modified'] + '</td>';
+            } else {
+              result += '<td></td>';
+            }
 
-          var cap_no_folders = ['upload', 'create'];
+            result += '</tr>';
+          });
 
-          data.Capabilities = cap_no_folders;
-          bindToolbar(data);
+          result += '</tbody>';
+          result += '</table>';
         }
+      } else {
+        if ($('.fileinfo').data('view') == 'grid') {
+          result += '<ul id="contents" class="grid"></ul>';
+        } else {
+          result += '<table id="contents" class="list tablesorter">';
+          result += '<thead><tr><th><span>' +
+            lg.name + '</span></th><th><span>' + lg.size +
+            '</span></th><th><span>' + lg.modified +
+            '</span></th></tr></thead>';
+          result += '<tbody>';
+        }
+        result += '<h1 class="no_folder_found">' +
+          lg.could_not_retrieve_folder + '</h1>';
 
-        // Add the new markup to the DOM.
-        $('.fileinfo .file_listing').html(result);
-        $('.fileinfo .file_listing #contents').tablesorter({
-          headers: {
-            2: {
-              sorter: 'shortDate',
-            },
+        var cap_no_folders = ['upload', 'create'];
+
+        data.Capabilities = cap_no_folders;
+        bindToolbar(data);
+      }
+
+      // Add the new markup to the DOM.
+      $('.fileinfo .file_listing').html(result);
+      $('.fileinfo .file_listing #contents').tablesorter({
+        headers: {
+          2: {
+            sorter: 'shortDate',
           },
-        });
+        },
+      });
 
-        // rename file/folder
-        $('.file_manager button.rename').off().on('click', function(e) {
+      // rename file/folder
+      $('.file_manager button.rename').off().on('click', function(e) {
 
-          if ($('.fileinfo').data('view') == 'grid') {
-            e.stopPropagation();
-            $this = $('.file_manager').find('#contents li.selected p');
-            orig_value = decodeURI($this.find('span').attr('title'));
-            newvalue = orig_value.substring(0, orig_value.indexOf('.'));
+        if ($('.fileinfo').data('view') == 'grid') {
+          e.stopPropagation();
+          $this = $('.file_manager').find('#contents li.selected p');
+          orig_value = decodeURI($this.find('span').attr('title'));
+          newvalue = orig_value.substring(0, orig_value.indexOf('.'));
+
+          if (newvalue === '') {
+            newvalue = decodeURI(orig_value);
+          }
 
-            if (newvalue === '') {
-              newvalue = decodeURI(orig_value);
+          $this.find('input').toggle().val(newvalue).trigger('focus');
+          $this.find('span').toggle();
+
+          // Rename folder/file on pressing enter key
+          $('.file_manager').off().on('keyup', function(e) {
+            if (e.keyCode == 13) {
+              e.stopPropagation();
+              $('.fileinfo #contents li.selected p').find(
+                'input'
+              ).trigger('blur');
             }
+          });
+        } else if ($('.fileinfo').data('view') == 'list') {
+          e.stopPropagation();
+          $this = $('.fileinfo').find(
+            'table#contents tbody tr.selected td:first-child p'
+          );
+          orig_value = decodeURI($this.find('span').html()),
+            newvalue = orig_value.substring(0, orig_value.lastIndexOf('.'));
 
-            $this.find('input').toggle().val(newvalue).trigger('focus');
-            $this.find('span').toggle();
+          if (orig_value.lastIndexOf('/') == orig_value.length - 1 || newvalue === '') {
+            newvalue = decodeURI(orig_value);
+          }
 
-            // Rename folder/file on pressing enter key
-            $('.file_manager').off().on('keyup', function(e) {
-              if (e.keyCode == 13) {
-                e.stopPropagation();
-                $('.fileinfo #contents li.selected p').find(
-                  'input'
-                ).trigger('blur');
-              }
-            });
-          } else if ($('.fileinfo').data('view') == 'list') {
-            e.stopPropagation();
-            $this = $('.fileinfo').find(
-              'table#contents tbody tr.selected td:first-child p'
-            );
-            orig_value = decodeURI($this.find('span').html()),
-              newvalue = orig_value.substring(0, orig_value.lastIndexOf('.'));
+          $this.find('input').toggle().val(newvalue).trigger('focus');
+          $this.find('span').toggle();
 
-            if (orig_value.lastIndexOf('/') == orig_value.length - 1 || newvalue === '') {
-              newvalue = decodeURI(orig_value);
+          // Rename folder/file on pressing enter key
+          $('.file_manager').off().on('keyup', function(e) {
+            if (e.keyCode == 13) {
+              e.stopPropagation();
+              $('.fileinfo table#contents tr.selected td p').find(
+                'input'
+              ).trigger('blur');
             }
+          });
+        }
+      });
 
-            $this.find('input').toggle().val(newvalue).trigger('focus');
-            $this.find('span').toggle();
+      // Rename UI handling
+      $('.fileinfo #contents li p').on('blur dblclick', 'input', function(e) {
+        e.stopPropagation();
 
-            // Rename folder/file on pressing enter key
-            $('.file_manager').off().on('keyup', function(e) {
-              if (e.keyCode == 13) {
-                e.stopPropagation();
-                $('.fileinfo table#contents tr.selected td p').find(
-                  'input'
-                ).trigger('blur');
-              }
-            });
+        var old_name = decodeURI($(this).siblings('span').attr('title'));
+        newvalue = old_name.substring(0, old_name.indexOf('.'));
+        var last = getFileExtension(old_name),
+          data, new_name, path, full_name;
+
+        if (old_name.indexOf('.') == 0) {
+          last = '';
+        }
+
+        if (newvalue == '') {
+          newvalue = decodeURI(old_name);
+        }
+
+        if (e.type == 'keydown') {
+          if (e.which == 13) {
+            full_name = decodeURI($(this).val()) + (
+              last !== '' ? '.' + last : ''
+            );
+
+            $(this).toggle();
+            $(this).siblings('span').toggle().html(full_name);
+
+            new_name = decodeURI($(this).val());
+            path = decodeURI($(this).parent().parent().find(
+              'span'
+            ).attr('data-alt'));
+            data = {
+              'Filename': old_name,
+              'Path': path,
+              'NewFilename': new_name,
+            };
+
+            if (newvalue !== new_name) {
+              renameItem(data);
+              var parent = $('.currentpath').val();
+              getFolderInfo(parent);
+            }
+            e.stopPropagation();
           }
-        });
 
-        // Rename UI handling
-        $('.fileinfo #contents li p').on('blur dblclick', 'input', function(e) {
-          e.stopPropagation();
+          if (
+            e.which == 38 || e.which == 40 || e.which == 37 ||
+            e.which == 39 || e.keyCode == 32
+          ) {
+            e.stopPropagation();
+          }
+        } else if (e.type == 'focusout') {
+          if ($(this).css('display') == 'inline-block' || $(this).css('display') == 'inline') {
+            full_name = decodeURI(
+              $(this).val()
+            ) + (last !== '' ? '.' + last : '');
+
+            $(this).toggle();
+            $(this).siblings('span').toggle().html(full_name);
+
+            new_name = decodeURI($(this).val());
+            path = decodeURI($(this).parent().parent().find(
+              'span'
+            ).attr('data-alt'));
+            data = {
+              'Filename': old_name,
+              'Path': path,
+              'NewFilename': new_name,
+            };
 
-          var old_name = decodeURI($(this).siblings('span').attr('title'));
-          newvalue = old_name.substring(0, old_name.indexOf('.'));
-          var last = getFileExtension(old_name),
-            data, new_name, path, full_name;
+            if (newvalue !== new_name) {
+              renameItem(data);
+              getFolderInfo($('.currentpath').val());
+            }
+          }
+        } else {
+          e.stopPropagation();
+        }
+      });
 
+      $('.fileinfo table#contents tr td p').on(
+        'blur dblclick', 'input',
+        function(e) {
+          var old_name = decodeURI($(this).siblings('span').attr('title')),
+            newvalue = old_name.substring(0, old_name.indexOf('.')),
+            last = getFileExtension(old_name);
           if (old_name.indexOf('.') == 0) {
             last = '';
           }
 
           if (newvalue == '') {
-            newvalue = decodeURI(old_name);
+            newvalue = old_name;
           }
 
-          if (e.type == 'keydown') {
-            if (e.which == 13) {
-              full_name = decodeURI($(this).val()) + (
+          if (e.type == 'focusout') {
+            if ($(this).css('display') == 'inline-block' || $(this).css('display') == 'inline') {
+              var full_name = decodeURI($(this).val()) + (
                 last !== '' ? '.' + last : ''
               );
-
               $(this).toggle();
               $(this).siblings('span').toggle().html(full_name);
 
-              new_name = decodeURI($(this).val());
-              path = decodeURI($(this).parent().parent().find(
-                'span'
-              ).attr('data-alt'));
-              data = {
-                'Filename': old_name,
-                'Path': path,
-                'NewFilename': new_name,
-              };
+              var new_name = decodeURI($(this).val()),
+                path = decodeURI($(this).parent().parent().attr('title')),
+                data = {
+                  'Filename': old_name,
+                  'Path': path,
+                  'NewFilename': new_name,
+                };
 
               if (newvalue !== new_name) {
                 renameItem(data);
-                var parent = $('.currentpath').val();
+                var parent = path.split('/').reverse().slice(2).reverse().join('/') + '/';
                 getFolderInfo(parent);
               }
-              e.stopPropagation();
-            }
-
-            if (
-              e.which == 38 || e.which == 40 || e.which == 37 ||
-              e.which == 39 || e.keyCode == 32
-            ) {
-              e.stopPropagation();
-            }
-          } else if (e.type == 'focusout') {
-            if ($(this).css('display') == 'inline-block' || $(this).css('display') == 'inline') {
-              full_name = decodeURI(
-                $(this).val()
-              ) + (last !== '' ? '.' + last : '');
-
-              $(this).toggle();
-              $(this).siblings('span').toggle().html(full_name);
-
-              new_name = decodeURI($(this).val());
-              path = decodeURI($(this).parent().parent().find(
-                'span'
-              ).attr('data-alt'));
-              data = {
-                'Filename': old_name,
-                'Path': path,
-                'NewFilename': new_name,
-              };
-
-              if (newvalue !== new_name) {
-                renameItem(data);
-                getFolderInfo($('.currentpath').val());
-              }
             }
           } else {
             e.stopPropagation();
           }
         });
 
-        $('.fileinfo table#contents tr td p').on(
-          'blur dblclick', 'input',
-          function(e) {
-            var old_name = decodeURI($(this).siblings('span').attr('title')),
-              newvalue = old_name.substring(0, old_name.indexOf('.')),
-              last = getFileExtension(old_name);
-            if (old_name.indexOf('.') == 0) {
-              last = '';
-            }
+      var data_cap = {};
+      data_cap.Capabilities = capabilities;
+      /*
+       * Bind click events
+       * Select items - afolder dblclick
+       */
+      if ($('.fileinfo').data('view') == 'grid') {
+        // Get into folder on dblclick
+        $('.fileinfo').find('#contents li').dblclick(function(e) {
+          e.stopPropagation();
+          // Enable/Disable level up button
+          enab_dis_level_up();
 
-            if (newvalue == '') {
-              newvalue = old_name;
-            }
+          var path = decodeURI($(this).find('span').attr('data-alt'));
 
-            if (e.type == 'focusout') {
-              if ($(this).css('display') == 'inline-block' || $(this).css('display') == 'inline') {
-                var full_name = decodeURI($(this).val()) + (
-                  last !== '' ? '.' + last : ''
-                );
-                $(this).toggle();
-                $(this).siblings('span').toggle().html(full_name);
-
-                var new_name = decodeURI($(this).val()),
-                  path = decodeURI($(this).parent().parent().attr('title')),
-                  data = {
-                    'Filename': old_name,
-                    'Path': path,
-                    'NewFilename': new_name,
-                  };
-
-                if (newvalue !== new_name) {
-                  renameItem(data);
-                  var parent = path.split('/').reverse().slice(2).reverse().join('/') + '/';
-                  getFolderInfo(parent);
-                }
-              }
-            } else {
-              e.stopPropagation();
-            }
-          });
+          if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
+            $('.file_manager_ok').addClass('disabled');
+            $('.file_manager_ok').attr('disabled', true);
+            $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
+            $('.file_manager button.download').attr('disabled', 'disabled');
 
-        var data_cap = {};
-        data_cap.Capabilities = capabilities;
-        /*
-         * Bind click events
-         * Select items - afolder dblclick
-         */
-        if ($('.fileinfo').data('view') == 'grid') {
-          // Get into folder on dblclick
-          $('.fileinfo').find('#contents li').dblclick(function(e) {
-            e.stopPropagation();
-            // Enable/Disable level up button
-            enab_dis_level_up();
+            getFolderInfo(path);
 
-            var path = decodeURI($(this).find('span').attr('data-alt'));
+          } else {
+            var is_valid_file = getFileInfo(path);
+            if (is_valid_file && check_file_capability(e, data_cap, 'grid')) {
+              $('.file_manager_ok').trigger('click');
+            }
+          }
+        });
 
-            if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
-              $('.file_manager_ok').addClass('disabled');
-              $('.file_manager_ok').attr('disabled', true);
-              $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
-              $('.file_manager button.download').attr('disabled', 'disabled');
+        $('.fileinfo').find('#contents li').on('click', function(e) {
+          e.stopPropagation();
+          var path = decodeURI($(this).find('.clip span').attr('data-alt')),
+            is_protected = $(this).find(
+              '.clip span.fm_lock_icon'
+            ).attr('data-protected');
 
-              getFolderInfo(path);
+          if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
+            if (
+              has_capability(data_cap, 'select_folder') &&
+              is_protected == undefined
+            ) {
+              $(this).parent().find('li.selected').removeClass('selected');
+              $(this).addClass('selected');
 
-            } else {
-              var is_valid_file = getFileInfo(path);
-              if (is_valid_file && check_file_capability(e, data_cap, 'grid')) {
-                $('.file_manager_ok').trigger('click');
-              }
+              $('.file_manager_ok').removeClass('disabled');
+              $('.file_manager_ok').attr('disabled', false);
+              $('.file_manager button.delete, .file_manager button.rename').removeAttr(
+                'disabled', 'disabled'
+              );
+              $('.file_manager button.download').attr(
+                'disabled', 'disabled'
+              );
+              // set selected folder name in breadcrums
+              $('.file_manager #uploader .input-path').hide();
+              $('.file_manager #uploader .show_selected_file').remove();
+              $('<span class="show_selected_file">' + path + '</span>').appendTo(
+                '.file_manager #uploader .filemanager-path-group'
+              );
+            }
+            pgAdmin.FileUtils.setUploader(path);
+          } else {
+            if (
+              has_capability(data_cap, 'select_file') &&
+              is_protected == undefined
+            ) {
+              $(this).parent().find('li.selected').removeClass('selected');
+              $(this).addClass('selected');
+              $('.file_manager_ok').removeClass('disabled');
+              $('.file_manager_ok').attr('disabled', false);
+              $('.file_manager button.delete, .file_manager button.download, .file_manager button.rename').removeAttr(
+                'disabled'
+              );
+              // set selected folder name in breadcrums
+              $('.file_manager #uploader .show_selected_file').remove();
             }
-          });
 
-          $('.fileinfo').find('#contents li').on('click', function(e) {
-            e.stopPropagation();
-            var path = decodeURI($(this).find('.clip span').attr('data-alt')),
-              is_protected = $(this).find(
-                '.clip span.fm_lock_icon'
-              ).attr('data-protected');
-
-            if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
-              if (
-                has_capability(data_cap, 'select_folder') &&
-                is_protected == undefined
-              ) {
-                $(this).parent().find('li.selected').removeClass('selected');
-                $(this).addClass('selected');
-
-                $('.file_manager_ok').removeClass('disabled');
-                $('.file_manager_ok').attr('disabled', false);
-                $('.file_manager button.delete, .file_manager button.rename').removeAttr(
-                  'disabled', 'disabled'
-                );
-                $('.file_manager button.download').attr(
-                  'disabled', 'disabled'
-                );
-                // set selected folder name in breadcrums
-                $('.file_manager #uploader .input-path').hide();
-                $('.file_manager #uploader .show_selected_file').remove();
-                $('<span class="show_selected_file">' + path + '</span>').appendTo(
-                  '.file_manager #uploader .filemanager-path-group'
-                );
-              }
-              pgAdmin.FileUtils.setUploader(path);
-            } else {
-              if (
-                has_capability(data_cap, 'select_file') &&
-                is_protected == undefined
-              ) {
-                $(this).parent().find('li.selected').removeClass('selected');
-                $(this).addClass('selected');
-                $('.file_manager_ok').removeClass('disabled');
-                $('.file_manager_ok').attr('disabled', false);
-                $('.file_manager button.delete, .file_manager button.download, .file_manager button.rename').removeAttr(
-                  'disabled'
-                );
-                // set selected folder name in breadcrums
-                $('.file_manager #uploader .show_selected_file').remove();
-              }
+            getFileInfo(path);
+          }
+        });
+      } else {
+        $('.fileinfo table#contents tbody tr').on('click', function(e) {
+          e.stopPropagation();
+          var path = decodeURI($('td:first-child', this).attr('title')),
+            is_protected = $('td:first-child', this).find(
+              'i.tbl_lock_icon'
+            ).attr('data-protected');
+
+          if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
+            if (has_capability(data_cap, 'select_folder') && is_protected == undefined) {
+              $(this).parent().find('tr.selected').removeClass('selected');
+              $('td:first-child', this).parent().addClass('selected');
+              $('.file_manager_ok').removeClass('disabled');
+              $('.file_manager_ok').attr('disabled', false);
+              $('.file_manager button.download').attr('disabled', 'disabled');
+              $('.file_manager button.delete, .file_manager button.rename').removeAttr('disabled');
 
-              getFileInfo(path);
+              // set selected folder name in breadcrums
+              $('.file_manager #uploader .input-path').hide();
+              $('.file_manager #uploader .show_selected_file').remove();
+              $('<span class="show_selected_file">' + path + '</span>').appendTo(
+                '.file_manager #uploader .filemanager-path-group'
+              );
             }
-          });
-        } else {
-          $('.fileinfo table#contents tbody tr').on('click', function(e) {
-            e.stopPropagation();
-            var path = decodeURI($('td:first-child', this).attr('title')),
-              is_protected = $('td:first-child', this).find(
-                'i.tbl_lock_icon'
-              ).attr('data-protected');
-
-            if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
-              if (has_capability(data_cap, 'select_folder') && is_protected == undefined) {
-                $(this).parent().find('tr.selected').removeClass('selected');
-                $('td:first-child', this).parent().addClass('selected');
-                $('.file_manager_ok').removeClass('disabled');
-                $('.file_manager_ok').attr('disabled', false);
-                $('.file_manager button.download').attr('disabled', 'disabled');
-                $('.file_manager button.delete, .file_manager button.rename').removeAttr('disabled');
-
-                // set selected folder name in breadcrums
-                $('.file_manager #uploader .input-path').hide();
-                $('.file_manager #uploader .show_selected_file').remove();
-                $('<span class="show_selected_file">' + path + '</span>').appendTo(
-                  '.file_manager #uploader .filemanager-path-group'
-                );
-              }
-              pgAdmin.FileUtils.setUploader(path);
-            } else {
-              if (has_capability(data_cap, 'select_file') && is_protected == undefined) {
-                $(this).parent().find('tr.selected').removeClass('selected');
-                $('td:first-child', this).parent().addClass('selected');
-                $('.file_manager button.delete, .file_manager button.download, .file_manager button.rename').removeAttr(
-                  'disabled'
-                );
-                // set selected folder name in breadcrums
-                $('.file_manager #uploader .show_selected_file').remove();
-              }
-
-              getFileInfo(path);
+            pgAdmin.FileUtils.setUploader(path);
+          } else {
+            if (has_capability(data_cap, 'select_file') && is_protected == undefined) {
+              $(this).parent().find('tr.selected').removeClass('selected');
+              $('td:first-child', this).parent().addClass('selected');
+              $('.file_manager button.delete, .file_manager button.download, .file_manager button.rename').removeAttr(
+                'disabled'
+              );
+              // set selected folder name in breadcrums
+              $('.file_manager #uploader .show_selected_file').remove();
             }
-          });
 
-          $('.fileinfo table#contents tbody tr').on('dblclick', function(e) {
-            e.stopPropagation();
-            // Enable/Disable level up button
-            enab_dis_level_up();
-            var path = $('td:first-child', this).attr('title');
+            getFileInfo(path);
+          }
+        });
 
-            if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
-              $('.file_manager_ok').addClass('disabled');
-              $('.file_manager_ok').attr('disabled', true);
-              $('.file_manager button.download').attr('disabled', 'disabled');
-              $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
-              getFolderInfo(path);
-            } else {
-              var is_valid_file = getFileInfo(path);
-              if (
-                is_valid_file && check_file_capability(e, data_cap, 'table')
-              ) {
-                $('.file_manager_ok').trigger('click');
-              }
+        $('.fileinfo table#contents tbody tr').on('dblclick', function(e) {
+          e.stopPropagation();
+          // Enable/Disable level up button
+          enab_dis_level_up();
+          var path = $('td:first-child', this).attr('title');
+
+          if (path.lastIndexOf('/') == path.length - 1 || path.lastIndexOf('\\') == path.length - 1) {
+            $('.file_manager_ok').addClass('disabled');
+            $('.file_manager_ok').attr('disabled', true);
+            $('.file_manager button.download').attr('disabled', 'disabled');
+            $('.file_manager button.delete, .file_manager button.rename').attr('disabled', 'disabled');
+            getFolderInfo(path);
+          } else {
+            var is_valid_file = getFileInfo(path);
+            if (
+              is_valid_file && check_file_capability(e, data_cap, 'table')
+            ) {
+              $('.file_manager_ok').trigger('click');
             }
-          });
+          }
+        });
 
-        }
-        //input_object.set_cap(data_cap);
-      },
-      error: function() {
-        $('.storage_dialog #uploader .input-path').prop('disabled', false);
-      },
+      }
+      //input_object.set_cap(data_cap);
+    })
+    .fail(function() {
+      $('.storage_dialog #uploader .input-path').prop('disabled', false);
     });
   };
 
diff --git a/web/pgadmin/misc/sql/static/js/sql.js b/web/pgadmin/misc/sql/static/js/sql.js
index 9ffa7b19..27c7ae55 100644
--- a/web/pgadmin/misc/sql/static/js/sql.js
+++ b/web/pgadmin/misc/sql/static/js/sql.js
@@ -105,30 +105,30 @@ define('misc.sql', [
                     );
                   }, 1000);
                 },
-                success: function(res) {
-                  if (pgAdmin.Browser.editor.getValue() != res) {
-                    pgAdmin.Browser.editor.setValue(res);
-                  }
-                  clearTimeout(timer);
-                },
-                error: function(xhr, error, message) {
-                  var _label = treeHierarchy[n_type].label;
-                  pgBrowser.Events.trigger(
-                    'pgadmin:node:retrieval:error', 'sql', xhr, error, message, item
+              })
+              .done(function(res) {
+                if (pgAdmin.Browser.editor.getValue() != res) {
+                  pgAdmin.Browser.editor.setValue(res);
+                }
+                clearTimeout(timer);
+              })
+              .fail(function(xhr, error, message) {
+                var _label = treeHierarchy[n_type].label;
+                pgBrowser.Events.trigger(
+                  'pgadmin:node:retrieval:error', 'sql', xhr, error, message, item
+                );
+                if (!Alertify.pgHandleItemError(xhr, error, message, {
+                  item: item,
+                  info: treeHierarchy,
+                })) {
+                  Alertify.pgNotifier(
+                    error, xhr,
+                    S(gettext('Error retrieving the information - %s')).sprintf(
+                      message || _label
+                    ).value(),
+                    function() {}
                   );
-                  if (!Alertify.pgHandleItemError(xhr, error, message, {
-                    item: item,
-                    info: treeHierarchy,
-                  })) {
-                    Alertify.pgNotifier(
-                      error, xhr,
-                      S(gettext('Error retrieving the information - %s')).sprintf(
-                        message || _label
-                      ).value(),
-                      function() {}
-                    );
-                  }
-                },
+                }
               });
             }
           }
diff --git a/web/pgadmin/misc/statistics/static/js/statistics.js b/web/pgadmin/misc/statistics/static/js/statistics.js
index 3ff88a0a..8a74bf18 100644
--- a/web/pgadmin/misc/statistics/static/js/statistics.js
+++ b/web/pgadmin/misc/statistics/static/js/statistics.js
@@ -229,65 +229,65 @@ define('misc.statistics', [
                 }
               }, 1000);
             },
-            success: function(res) {
-              // clear timer and reset message.
-              clearTimeout(timer);
-              $msgContainer.text('');
-              if (res.data) {
-                var data = res.data;
-                if (node.hasCollectiveStatistics || data['rows'].length > 1) {
-                  self.__createMultiLineStatistics.call(self, data, node.statsPrettifyFields);
-                } else {
-                  self.__createSingleLineStatistics.call(self, data, node.statsPrettifyFields);
-                }
+          })
+          .done(function(res) {
+            // clear timer and reset message.
+            clearTimeout(timer);
+            $msgContainer.text('');
+            if (res.data) {
+              var data = res.data;
+              if (node.hasCollectiveStatistics || data['rows'].length > 1) {
+                self.__createMultiLineStatistics.call(self, data, node.statsPrettifyFields);
+              } else {
+                self.__createSingleLineStatistics.call(self, data, node.statsPrettifyFields);
+              }
 
-                if (self.grid) {
-                  delete self.grid;
-                  self.grid = null;
-                }
+              if (self.grid) {
+                delete self.grid;
+                self.grid = null;
+              }
 
-                self.grid = new Backgrid.Grid({
-                  columns: self.columns,
-                  collection: self.collection,
-                  className: GRID_CLASSES,
-                });
-                self.grid.render();
-                $gridContainer.empty();
-                $gridContainer.append(self.grid.$el);
-
-                if (!$msgContainer.hasClass('hidden')) {
-                  $msgContainer.addClass('hidden');
-                }
-                $gridContainer.removeClass('hidden');
+              self.grid = new Backgrid.Grid({
+                columns: self.columns,
+                collection: self.collection,
+                className: GRID_CLASSES,
+              });
+              self.grid.render();
+              $gridContainer.empty();
+              $gridContainer.append(self.grid.$el);
+
+              if (!$msgContainer.hasClass('hidden')) {
+                $msgContainer.addClass('hidden');
+              }
+              $gridContainer.removeClass('hidden');
 
-              } else if (res.info) {
-                if (!$gridContainer.hasClass('hidden')) {
-                  $gridContainer.addClass('hidden');
-                }
-                $msgContainer.text(res.info);
-                $msgContainer.removeClass('hidden');
+            } else if (res.info) {
+              if (!$gridContainer.hasClass('hidden')) {
+                $gridContainer.addClass('hidden');
               }
-            },
-            error: function(xhr, error, message) {
-              var _label = treeHierarchy[n_type].label;
-              pgBrowser.Events.trigger(
-                'pgadmin:node:retrieval:error', 'statistics', xhr, error, message, item
+              $msgContainer.text(res.info);
+              $msgContainer.removeClass('hidden');
+            }
+          })
+          .fail(function(xhr, error, message) {
+            var _label = treeHierarchy[n_type].label;
+            pgBrowser.Events.trigger(
+              'pgadmin:node:retrieval:error', 'statistics', xhr, error, message, item
+            );
+            if (!Alertify.pgHandleItemError(xhr, error, message, {
+              item: item,
+              info: treeHierarchy,
+            })) {
+              Alertify.pgNotifier(
+                error, xhr,
+                S(gettext('Error retrieving the information - %s')).sprintf(
+                  message || _label
+                ).value(),
+                function() {}
               );
-              if (!Alertify.pgHandleItemError(xhr, error, message, {
-                item: item,
-                info: treeHierarchy,
-              })) {
-                Alertify.pgNotifier(
-                  error, xhr,
-                  S(gettext('Error retrieving the information - %s')).sprintf(
-                    message || _label
-                  ).value(),
-                  function() {}
-                );
-              }
-              // show failed message.
-              $msgContainer.text(gettext('Failed to retrieve data from the server.'));
-            },
+            }
+            // show failed message.
+            $msgContainer.text(gettext('Failed to retrieve data from the server.'));
           });
         }
       }
diff --git a/web/pgadmin/settings/static/js/settings.js b/web/pgadmin/settings/static/js/settings.js
index 634368cf..bcb9df77 100644
--- a/web/pgadmin/settings/static/js/settings.js
+++ b/web/pgadmin/settings/static/js/settings.js
@@ -33,18 +33,18 @@ define('pgadmin.settings', [
             url: url_for('settings.reset_layout'),
             type: 'DELETE',
             async: false,
-            success: function() {
-              // Prevent saving layout on server for next page reload.
-              $(window).unbind('unload');
-              window.onbeforeunload = null;
-              // Now reload page
-              location.reload(true);
-            },
-            error: function() {
-              console.warn(
-                'Something went wrong on server while resetting layout.'
-              );
-            },
+          })
+          .done(function() {
+            // Prevent saving layout on server for next page reload.
+            $(window).unbind('unload');
+            window.onbeforeunload = null;
+            // Now reload page
+            location.reload(true);
+          })
+          .fail(function() {
+            console.warn(
+              'Something went wrong on server while resetting layout.'
+            );
           });
 
         },
diff --git a/web/pgadmin/static/js/alertify.pgadmin.defaults.js b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
index 7c499802..91350baa 100644
--- a/web/pgadmin/static/js/alertify.pgadmin.defaults.js
+++ b/web/pgadmin/static/js/alertify.pgadmin.defaults.js
@@ -337,25 +337,25 @@ define([
           null, 'connect', args.info.server, true, args.info
         ),
         dataType: 'json',
-        success: function(res) {
-          if (res.success && 'connected' in res.data) {
-            if (res.data.connected) {
-              // Server is connected, but - the connection with the
-              // particular database has been lost.
-              pgBrowser.Events.trigger(
-                'pgadmin:database:connection:lost', args.item, jsonResp
-              );
-              return;
-            }
+      })
+      .done(function(res) {
+        if (res.success && 'connected' in res.data) {
+          if (res.data.connected) {
+            // Server is connected, but - the connection with the
+            // particular database has been lost.
+            pgBrowser.Events.trigger(
+              'pgadmin:database:connection:lost', args.item, jsonResp
+            );
+            return;
           }
+        }
 
-          // Serever was not connected, we should first try to connect
-          // the server.
-          reconnectServer();
-        },
-        error: function() {
-          reconnectServer();
-        },
+        // Serever was not connected, we should first try to connect
+        // the server.
+        reconnectServer();
+      })
+      .fail(function() {
+        reconnectServer();
       });
       return true;
     }
diff --git a/web/pgadmin/static/js/sqleditor_utils.js b/web/pgadmin/static/js/sqleditor_utils.js
index 0fff1d95..c131e22c 100644
--- a/web/pgadmin/static/js/sqleditor_utils.js
+++ b/web/pgadmin/static/js/sqleditor_utils.js
@@ -79,102 +79,102 @@ define(['jquery', 'sources/gettext', 'sources/url_for'],
         $.ajax({
           url: url,
           method: 'GET',
-          success: function (res) {
-            if(res && res.data) {
-              var status = res.data.status,
-                msg = res.data.message,
-                is_status_changed = false;
+        })
+        .done(function (res) {
+          if(res && res.data) {
+            var status = res.data.status,
+              msg = res.data.message,
+              is_status_changed = false;
 
-              // Raise notify messages comes from database server.
-              sqleditor_obj.update_notifications(res.data.notifies);
+            // Raise notify messages comes from database server.
+            sqleditor_obj.update_notifications(res.data.notifies);
 
-              // Inject CSS as required
-              switch(status) {
-                  // Busy
-              case 1:
-                      // if received busy status more than once then only
-                if(status == sqlEditorUtils.previousStatus &&
-                          !$status_el.hasClass('fa-hourglass-half')) {
-                  $status_el.removeClass()
-                                  .addClass('fa fa-hourglass-half');
-                  is_status_changed = true;
-                }
-                break;
-                  // Idle in transaction
-              case 2:
-                if(sqlEditorUtils.previousStatus != status &&
-                          !$status_el.hasClass('fa-clock-o')) {
-                  $status_el.removeClass()
-                                  .addClass('fa fa-clock-o');
-                  is_status_changed = true;
-                }
-                break;
-                  // Failed in transaction
-              case 3:
-                if(sqlEditorUtils.previousStatus != status &&
-                          !$status_el.hasClass('fa-exclamation-circle')) {
-                  $status_el.removeClass()
-                                  .addClass('fa fa-exclamation-circle');
-                  is_status_changed = true;
-                }
-                break;
-                  // Failed in transaction with unknown server side error
-              case 4:
-                if(sqlEditorUtils.previousStatus != status &&
-                          !$status_el.hasClass('fa-exclamation-triangle')) {
-                  $status_el.removeClass()
-                                  .addClass('fa fa-exclamation-triangle');
-                  is_status_changed = true;
-                }
-                break;
-              default:
-                if(sqlEditorUtils.previousStatus != status &&
-                          !$status_el.hasClass('fa-query_tool_connected')) {
-                  $status_el.removeClass()
-                                  .addClass('fa-custom fa-query-tool-connected');
-                  is_status_changed = true;
-                }
+            // Inject CSS as required
+            switch(status) {
+                // Busy
+            case 1:
+                    // if received busy status more than once then only
+              if(status == sqlEditorUtils.previousStatus &&
+                        !$status_el.hasClass('fa-hourglass-half')) {
+                $status_el.removeClass()
+                                .addClass('fa fa-hourglass-half');
+                is_status_changed = true;
               }
-
-              sqlEditorUtils.previousStatus = status;
-              // Set bootstrap popover message
-              if(is_status_changed) {
-                $el.popover('hide');
-                $el.attr('data-content', msg);
+              break;
+                // Idle in transaction
+            case 2:
+              if(sqlEditorUtils.previousStatus != status &&
+                        !$status_el.hasClass('fa-clock-o')) {
+                $status_el.removeClass()
+                                .addClass('fa fa-clock-o');
+                is_status_changed = true;
               }
-            } else {
-              // We come here means we did not receive expected response
-              // from server, we need to error out
-              sqlEditorUtils.previousStatus = -99;
-              msg = gettext('An unexpected error occurred - ' +
-                            'ensure you are logged into the application.');
-              $el.attr('data-content', msg);
-              if(!$status_el.hasClass('fa-query-tool-disconnected')) {
-                $el.popover('hide');
+              break;
+                // Failed in transaction
+            case 3:
+              if(sqlEditorUtils.previousStatus != status &&
+                        !$status_el.hasClass('fa-exclamation-circle')) {
                 $status_el.removeClass()
-                          .addClass('fa-custom fa-query-tool-disconnected');
+                                .addClass('fa fa-exclamation-circle');
+                is_status_changed = true;
+              }
+              break;
+                // Failed in transaction with unknown server side error
+            case 4:
+              if(sqlEditorUtils.previousStatus != status &&
+                        !$status_el.hasClass('fa-exclamation-triangle')) {
+                $status_el.removeClass()
+                                .addClass('fa fa-exclamation-triangle');
+                is_status_changed = true;
+              }
+              break;
+            default:
+              if(sqlEditorUtils.previousStatus != status &&
+                        !$status_el.hasClass('fa-query_tool_connected')) {
+                $status_el.removeClass()
+                                .addClass('fa-custom fa-query-tool-connected');
+                is_status_changed = true;
               }
-            }
-          },
-          error: function (e) {
-            sqlEditorUtils.previousStatus = -1;
-            var msg = gettext('Transaction status check failed.');
-            if (e.readyState == 0) {
-              msg = gettext('Not connected to the server or the connection to ' +
-                            'the server has been closed.');
-            } else if (e.responseJSON && e.responseJSON.errormsg) {
-              msg = e.responseJSON.errormsg;
             }
 
-            // Set bootstrap popover
+            sqlEditorUtils.previousStatus = status;
+            // Set bootstrap popover message
+            if(is_status_changed) {
+              $el.popover('hide');
+              $el.attr('data-content', msg);
+            }
+          } else {
+            // We come here means we did not receive expected response
+            // from server, we need to error out
+            sqlEditorUtils.previousStatus = -99;
+            msg = gettext('An unexpected error occurred - ' +
+                          'ensure you are logged into the application.');
             $el.attr('data-content', msg);
-            // Add error class
             if(!$status_el.hasClass('fa-query-tool-disconnected')) {
               $el.popover('hide');
               $status_el.removeClass()
                         .addClass('fa-custom fa-query-tool-disconnected');
             }
-          },
+          }
+        })
+        .fail(function (e) {
+          sqlEditorUtils.previousStatus = -1;
+          var msg = gettext('Transaction status check failed.');
+          if (e.readyState == 0) {
+            msg = gettext('Not connected to the server or the connection to ' +
+                          'the server has been closed.');
+          } else if (e.responseJSON && e.responseJSON.errormsg) {
+            msg = e.responseJSON.errormsg;
+          }
+
+          // Set bootstrap popover
+          $el.attr('data-content', msg);
+          // Add error class
+          if(!$status_el.hasClass('fa-query-tool-disconnected')) {
+            $el.popover('hide');
+            $status_el.removeClass()
+                      .addClass('fa-custom fa-query-tool-disconnected');
+          }
         });
       },
 
diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid.js b/web/pgadmin/tools/datagrid/static/js/datagrid.js
index 4cdddf38..93e00bc4 100644
--- a/web/pgadmin/tools/datagrid/static/js/datagrid.js
+++ b/web/pgadmin/tools/datagrid/static/js/datagrid.js
@@ -323,24 +323,24 @@ define('pgadmin.datagrid', [
                     async: false,
                     contentType: 'application/json',
                     data: JSON.stringify(sql),
-                    success: function(res) {
-                      if (res.data.status) {
-                        // Initialize the data grid.
-                        self.create_transaction(that.baseUrl, null, 'false', parentData.server.server_type, '', grid_title, sql, false);
-                      }
-                      else {
-                        alertify.alert(
-                          gettext('Validation Error'),
-                            res.data.result
-                        );
-                      }
-                    },
-                    error: function(e) {
+                  })
+                  .done(function(res) {
+                    if (res.data.status) {
+                      // Initialize the data grid.
+                      self.create_transaction(that.baseUrl, null, 'false', parentData.server.server_type, '', grid_title, sql, false);
+                    }
+                    else {
                       alertify.alert(
                         gettext('Validation Error'),
-                        e
+                          res.data.result
                       );
-                    },
+                    }
+                  })
+                  .fail(function(e) {
+                    alertify.alert(
+                      gettext('Validation Error'),
+                      e
+                    );
                   });
                 }
               },
@@ -376,35 +376,35 @@ define('pgadmin.datagrid', [
           dataType: 'json',
           data: JSON.stringify(sql_filter),
           contentType: 'application/json',
-          success: function(res) {
-            res.data.is_query_tool = is_query_tool;
-            res.data.server_type = server_type;
-            res.data.sURL = sURL;
-            res.data.panel_title = panel_title;
-            target.trigger('pgadmin-datagrid:transaction:created', res.data);
-          },
-          error: function(xhr) {
-            if (target !== self) {
-              if(xhr.status == 503 && xhr.responseJSON.info != undefined &&
-                  xhr.responseJSON.info == 'CONNECTION_LOST') {
-                setTimeout(function() {
-                  target.handle_connection_lost(true, xhr);
-                });
-                return;
-              }
+        })
+        .done(function(res) {
+          res.data.is_query_tool = is_query_tool;
+          res.data.server_type = server_type;
+          res.data.sURL = sURL;
+          res.data.panel_title = panel_title;
+          target.trigger('pgadmin-datagrid:transaction:created', res.data);
+        })
+        .fail(function(xhr) {
+          if (target !== self) {
+            if(xhr.status == 503 && xhr.responseJSON.info != undefined &&
+                xhr.responseJSON.info == 'CONNECTION_LOST') {
+              setTimeout(function() {
+                target.handle_connection_lost(true, xhr);
+              });
+              return;
             }
+          }
 
-            try {
-              var err = JSON.parse(xhr.responseText);
-              alertify.alert(gettext('Query Tool Initialize Error'),
-                err.errormsg
-              );
-            } catch (e) {
-              alertify.alert(
-                e.statusText, gettext('Query Tool Initialize Error')
-              );
-            }
-          },
+          try {
+            var err = JSON.parse(xhr.responseText);
+            alertify.alert(gettext('Query Tool Initialize Error'),
+              err.errormsg
+            );
+          } catch (e) {
+            alertify.alert(
+              e.statusText, gettext('Query Tool Initialize Error')
+            );
+          }
         });
       },
       launch_grid: function(trans_obj) {
diff --git a/web/pgadmin/tools/debugger/static/js/debugger.js b/web/pgadmin/tools/debugger/static/js/debugger.js
index b1a2929c..d632343e 100644
--- a/web/pgadmin/tools/debugger/static/js/debugger.js
+++ b/web/pgadmin/tools/debugger/static/js/debugger.js
@@ -291,19 +291,19 @@ define([
       $.ajax({
         url: _url,
         cache: false,
-        success: function() {
-          self.start_global_debugger();
-        },
-        error: function(xhr) {
-          try {
-            var err = JSON.parse(xhr.responseText);
-            if (err.success == 0) {
-              Alertify.alert(gettext('Debugger Error'), err.errormsg);
-            }
-          } catch (e) {
-            console.warn(e.stack || e);
+      })
+      .done(function() {
+        self.start_global_debugger();
+      })
+      .fail(function(xhr) {
+        try {
+          var err = JSON.parse(xhr.responseText);
+          if (err.success == 0) {
+            Alertify.alert(gettext('Debugger Error'), err.errormsg);
           }
-        },
+        } catch (e) {
+          console.warn(e.stack || e);
+        }
       });
     },
 
@@ -378,52 +378,52 @@ define([
       $.ajax({
         url: baseUrl,
         method: 'GET',
-        success: function(res) {
-          var url = url_for('debugger.direct', {
-            'trans_id': res.data.debuggerTransId,
-          });
+      })
+      .done(function(res) {
+        var url = url_for('debugger.direct', {
+          'trans_id': res.data.debuggerTransId,
+        });
 
-          if (res.data.newBrowserTab) {
-            window.open(url, '_blank');
-          } else {
-            pgBrowser.Events.once(
-              'pgadmin-browser:frame:urlloaded:frm_debugger',
-              function(frame) {
-                frame.openURL(url);
-              });
+        if (res.data.newBrowserTab) {
+          window.open(url, '_blank');
+        } else {
+          pgBrowser.Events.once(
+            'pgadmin-browser:frame:urlloaded:frm_debugger',
+            function(frame) {
+              frame.openURL(url);
+            });
 
-            // Create the debugger panel as per the data received from user input dialog.
-            var dashboardPanel = pgBrowser.docker.findPanels(
-                'properties'
-              ),
-              panel = pgBrowser.docker.addPanel(
-                'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
-              );
+          // Create the debugger panel as per the data received from user input dialog.
+          var dashboardPanel = pgBrowser.docker.findPanels(
+              'properties'
+            ),
+            panel = pgBrowser.docker.addPanel(
+              'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
+            );
 
-            panel.focus();
+          panel.focus();
 
-            // Panel Closed event
-            panel.on(wcDocker.EVENT.CLOSED, function() {
-              var closeUrl = url_for('debugger.close', {
-                'trans_id': res.data.debuggerTransId,
-              });
-              $.ajax({
-                url: closeUrl,
-                method: 'DELETE',
-              });
+          // Panel Closed event
+          panel.on(wcDocker.EVENT.CLOSED, function() {
+            var closeUrl = url_for('debugger.close', {
+              'trans_id': res.data.debuggerTransId,
             });
+            $.ajax({
+              url: closeUrl,
+              method: 'DELETE',
+            });
+          });
+        }
+      })
+      .fail(function(xhr) {
+        try {
+          var err = JSON.parse(xhr.responseText);
+          if (err.success == 0) {
+            Alertify.alert(gettext('Debugger Error'), err.errormsg);
           }
-        },
-        error: function(xhr) {
-          try {
-            var err = JSON.parse(xhr.responseText);
-            if (err.success == 0) {
-              Alertify.alert(gettext('Debugger Error'), err.errormsg);
-            }
-          } catch (e) {
-            console.warn(e.stack || e);
-          }
-        },
+        } catch (e) {
+          console.warn(e.stack || e);
+        }
       });
     },
 
@@ -446,107 +446,107 @@ define([
       $.ajax({
         url: _url,
         cache: false,
-        success: function(res) {
-
-          // Open Alertify the dialog to take the input arguments from user if function having input arguments
-          if (res.data[0]['require_input']) {
-            get_function_arguments(res.data[0], 0);
+      })
+      .done(function(res) {
+
+        // Open Alertify the dialog to take the input arguments from user if function having input arguments
+        if (res.data[0]['require_input']) {
+          get_function_arguments(res.data[0], 0);
+        } else {
+          // Initialize the target and create asynchronous connection and unique transaction ID
+          // If there is no arguments to the functions then we should not ask for for function arguments and
+          // Directly open the panel
+          var t = pgBrowser.tree,
+            i = t.selected(),
+            d = i && i.length == 1 ? t.itemData(i) : undefined,
+            node = d && pgBrowser.Nodes[d._type];
+
+          if (!d)
+            return;
+
+          var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
+            baseUrl;
+
+          if (d._type == 'function') {
+            baseUrl = url_for(
+              'debugger.initialize_target_for_function', {
+                'debug_type': 'direct',
+                'sid': treeInfo.server._id,
+                'did': treeInfo.database._id,
+                'scid': treeInfo.schema._id,
+                'func_id': treeInfo.function._id,
+              }
+            );
           } else {
-            // Initialize the target and create asynchronous connection and unique transaction ID
-            // If there is no arguments to the functions then we should not ask for for function arguments and
-            // Directly open the panel
-            var t = pgBrowser.tree,
-              i = t.selected(),
-              d = i && i.length == 1 ? t.itemData(i) : undefined,
-              node = d && pgBrowser.Nodes[d._type];
-
-            if (!d)
-              return;
-
-            var treeInfo = node.getTreeNodeHierarchy.apply(node, [i]),
-              baseUrl;
-
-            if (d._type == 'function') {
-              baseUrl = url_for(
-                'debugger.initialize_target_for_function', {
-                  'debug_type': 'direct',
-                  'sid': treeInfo.server._id,
-                  'did': treeInfo.database._id,
-                  'scid': treeInfo.schema._id,
-                  'func_id': treeInfo.function._id,
-                }
-              );
-            } else {
-              baseUrl = url_for(
-                'debugger.initialize_target_for_function', {
-                  'debug_type': 'direct',
-                  'sid': treeInfo.server._id,
-                  'did': treeInfo.database._id,
-                  'scid': treeInfo.schema._id,
-                  'func_id': debuggerUtils.getProcedureId(treeInfo),
-                }
-              );
-            }
+            baseUrl = url_for(
+              'debugger.initialize_target_for_function', {
+                'debug_type': 'direct',
+                'sid': treeInfo.server._id,
+                'did': treeInfo.database._id,
+                'scid': treeInfo.schema._id,
+                'func_id': debuggerUtils.getProcedureId(treeInfo),
+              }
+            );
+          }
 
-            $.ajax({
-              url: baseUrl,
-              method: 'GET',
-              success: function(res) {
+          $.ajax({
+            url: baseUrl,
+            method: 'GET',
+          })
+          .done(function(res) {
 
-                var url = url_for('debugger.direct', {
-                  'trans_id': res.data.debuggerTransId,
+            var url = url_for('debugger.direct', {
+              'trans_id': res.data.debuggerTransId,
+            });
+
+            if (res.data.newBrowserTab) {
+              window.open(url, '_blank');
+            } else {
+              pgBrowser.Events.once(
+                'pgadmin-browser:frame:urlloaded:frm_debugger',
+                function(frame) {
+                  frame.openURL(url);
                 });
 
-                if (res.data.newBrowserTab) {
-                  window.open(url, '_blank');
-                } else {
-                  pgBrowser.Events.once(
-                    'pgadmin-browser:frame:urlloaded:frm_debugger',
-                    function(frame) {
-                      frame.openURL(url);
-                    });
-
-                  // Create the debugger panel as per the data received from user input dialog.
-                  var dashboardPanel = pgBrowser.docker.findPanels(
-                      'properties'
-                    ),
-                    panel = pgBrowser.docker.addPanel(
-                      'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
-                    );
-
-                  panel.focus();
-
-                  // Register Panel Closed event
-                  panel.on(wcDocker.EVENT.CLOSED, function() {
-                    var closeUrl = url_for('debugger.close', {
-                      'trans_id': res.data.debuggerTransId,
-                    });
-                    $.ajax({
-                      url: closeUrl,
-                      method: 'DELETE',
-                    });
-                  });
-                }
-              },
-              error: function(e) {
-                Alertify.alert(
-                  gettext('Debugger Target Initialization Error'),
-                  e.responseJSON.errormsg
+              // Create the debugger panel as per the data received from user input dialog.
+              var dashboardPanel = pgBrowser.docker.findPanels(
+                  'properties'
+                ),
+                panel = pgBrowser.docker.addPanel(
+                  'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
                 );
-              },
-            });
-          }
-        },
-        error: function(xhr) {
-          try {
-            var err = JSON.parse(xhr.responseText);
-            if (err.success == 0) {
-              Alertify.alert(gettext('Debugger Error'), err.errormsg);
+
+              panel.focus();
+
+              // Register Panel Closed event
+              panel.on(wcDocker.EVENT.CLOSED, function() {
+                var closeUrl = url_for('debugger.close', {
+                  'trans_id': res.data.debuggerTransId,
+                });
+                $.ajax({
+                  url: closeUrl,
+                  method: 'DELETE',
+                });
+              });
             }
-          } catch (e) {
-            console.warn(e.stack || e);
+          })
+          .fail(function(e) {
+            Alertify.alert(
+              gettext('Debugger Target Initialization Error'),
+              e.responseJSON.errormsg
+            );
+          });
+        }
+      })
+      .fail(function(xhr) {
+        try {
+          var err = JSON.parse(xhr.responseText);
+          if (err.success == 0) {
+            Alertify.alert(gettext('Debugger Error'), err.errormsg);
           }
-        },
+        } catch (e) {
+          console.warn(e.stack || e);
+        }
       });
     },
   };
diff --git a/web/pgadmin/tools/debugger/static/js/debugger_ui.js b/web/pgadmin/tools/debugger/static/js/debugger_ui.js
index d88ac87e..6f6fad5b 100644
--- a/web/pgadmin/tools/debugger/static/js/debugger_ui.js
+++ b/web/pgadmin/tools/debugger/static/js/debugger_ui.js
@@ -192,26 +192,26 @@ define([
               url: _Url,
               method: 'GET',
               async: false,
-              success: function(res) {
-                if (res.data.args_count != 0) {
-                  for (i = 0; i < res.data.result.length; i++) {
-                    // Below will format the data to be stored in sqlite database
-                    func_args_data.push({
-                      'arg_id': res.data.result[i]['arg_id'],
-                      'is_null': res.data.result[i]['is_null'],
-                      'is_expression': res.data.result[i]['is_expression'],
-                      'use_default': res.data.result[i]['use_default'],
-                      'value': res.data.result[i]['value'],
-                    });
-                  }
+            })
+            .done(function(res) {
+              if (res.data.args_count != 0) {
+                for (i = 0; i < res.data.result.length; i++) {
+                  // Below will format the data to be stored in sqlite database
+                  func_args_data.push({
+                    'arg_id': res.data.result[i]['arg_id'],
+                    'is_null': res.data.result[i]['is_null'],
+                    'is_expression': res.data.result[i]['is_expression'],
+                    'use_default': res.data.result[i]['use_default'],
+                    'value': res.data.result[i]['value'],
+                  });
                 }
-              },
-              error: function() {
-                Alertify.alert(
-                  gettext('Debugger Error'),
-                  gettext('Unable to fetch the arguments from server')
-                );
-              },
+              }
+            })
+            .fail(function() {
+              Alertify.alert(
+                gettext('Debugger Error'),
+                gettext('Unable to fetch the arguments from server')
+              );
             });
 
             var argname, argtype, argmode, default_args_count, default_args, arg_cnt;
@@ -701,97 +701,97 @@ define([
                   data: {
                     'data': JSON.stringify(args_value_list),
                   },
-                  success: function(res) {
+                })
+                .done(function(res) {
 
-                    var url = url_for(
-                      'debugger.direct', {
-                        'trans_id': res.data.debuggerTransId,
-                      }
-                    );
+                  var url = url_for(
+                    'debugger.direct', {
+                      'trans_id': res.data.debuggerTransId,
+                    }
+                  );
 
-                    if (res.data.newBrowserTab) {
-                      window.open(url, '_blank');
-                    } else {
-                      pgBrowser.Events.once(
-                        'pgadmin-browser:frame:urlloaded:frm_debugger',
-                        function(frame) {
-                          frame.openURL(url);
-                        });
+                  if (res.data.newBrowserTab) {
+                    window.open(url, '_blank');
+                  } else {
+                    pgBrowser.Events.once(
+                      'pgadmin-browser:frame:urlloaded:frm_debugger',
+                      function(frame) {
+                        frame.openURL(url);
+                      });
 
-                      // Create the debugger panel as per the data received from user input dialog.
-                      var dashboardPanel = pgBrowser.docker.findPanels('properties'),
-                        panel = pgBrowser.docker.addPanel(
-                          'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
-                        );
+                    // Create the debugger panel as per the data received from user input dialog.
+                    var dashboardPanel = pgBrowser.docker.findPanels('properties'),
+                      panel = pgBrowser.docker.addPanel(
+                        'frm_debugger', wcDocker.DOCK.STACKED, dashboardPanel[0]
+                      );
 
-                      panel.focus();
+                    panel.focus();
 
-                      // Panel Closed event
-                      panel.on(wcDocker.EVENT.CLOSED, function() {
-                        var closeUrl = url_for('debugger.close', {
-                          'trans_id': res.data.debuggerTransId,
-                        });
-                        $.ajax({
-                          url: closeUrl,
-                          method: 'DELETE',
-                        });
-                      });
-                    }
-                    var _Url;
-
-                    if (d._type == 'function') {
-                      _Url = url_for('debugger.set_arguments', {
-                        'sid': treeInfo.server._id,
-                        'did': treeInfo.database._id,
-                        'scid': treeInfo.schema._id,
-                        'func_id': treeInfo.function._id,
-                      });
-                    } else if (d._type == 'procedure') {
-                      _Url = url_for('debugger.set_arguments', {
-                        'sid': treeInfo.server._id,
-                        'did': treeInfo.database._id,
-                        'scid': treeInfo.schema._id,
-                        'func_id': treeInfo.procedure._id,
-                      });
-                    } else if (d._type == 'edbfunc') {
-                      // Get the existing function parameters available from sqlite database
-                      _Url = url_for('debugger.set_arguments', {
-                        'sid': treeInfo.server._id,
-                        'did': treeInfo.database._id,
-                        'scid': treeInfo.schema._id,
-                        'func_id': treeInfo.edbfunc._id,
+                    // Panel Closed event
+                    panel.on(wcDocker.EVENT.CLOSED, function() {
+                      var closeUrl = url_for('debugger.close', {
+                        'trans_id': res.data.debuggerTransId,
                       });
-                    } else if (d._type == 'edbproc') {
-                      // Get the existing function parameters available from sqlite database
-                      _Url = url_for('debugger.set_arguments', {
-                        'sid': treeInfo.server._id,
-                        'did': treeInfo.database._id,
-                        'scid': treeInfo.schema._id,
-                        'func_id': treeInfo.edbproc._id,
+                      $.ajax({
+                        url: closeUrl,
+                        method: 'DELETE',
                       });
-                    }
+                    });
+                  }
+                  var _Url;
 
-                    $.ajax({
-                      url: _Url,
-                      method: 'POST',
-                      data: {
-                        'data': JSON.stringify(sqlite_func_args_list),
-                      },
-                      success: function() {},
-                      error: function() {
-                        Alertify.alert(
-                          gettext('Debugger Error'),
-                          gettext('Unable to set the arguments on the server')
-                        );
-                      },
+                  if (d._type == 'function') {
+                    _Url = url_for('debugger.set_arguments', {
+                      'sid': treeInfo.server._id,
+                      'did': treeInfo.database._id,
+                      'scid': treeInfo.schema._id,
+                      'func_id': treeInfo.function._id,
                     });
-                  },
-                  error: function(e) {
+                  } else if (d._type == 'procedure') {
+                    _Url = url_for('debugger.set_arguments', {
+                      'sid': treeInfo.server._id,
+                      'did': treeInfo.database._id,
+                      'scid': treeInfo.schema._id,
+                      'func_id': treeInfo.procedure._id,
+                    });
+                  } else if (d._type == 'edbfunc') {
+                    // Get the existing function parameters available from sqlite database
+                    _Url = url_for('debugger.set_arguments', {
+                      'sid': treeInfo.server._id,
+                      'did': treeInfo.database._id,
+                      'scid': treeInfo.schema._id,
+                      'func_id': treeInfo.edbfunc._id,
+                    });
+                  } else if (d._type == 'edbproc') {
+                    // Get the existing function parameters available from sqlite database
+                    _Url = url_for('debugger.set_arguments', {
+                      'sid': treeInfo.server._id,
+                      'did': treeInfo.database._id,
+                      'scid': treeInfo.schema._id,
+                      'func_id': treeInfo.edbproc._id,
+                    });
+                  }
+
+                  $.ajax({
+                    url: _Url,
+                    method: 'POST',
+                    data: {
+                      'data': JSON.stringify(sqlite_func_args_list),
+                    },
+                  })
+                  .done(function() {})
+                  .fail(function() {
                     Alertify.alert(
-                      gettext('Debugger Target Initialization Error'),
-                      e.responseJSON.errormsg
+                      gettext('Debugger Error'),
+                      gettext('Unable to set the arguments on the server')
                     );
-                  },
+                  });
+                })
+                .fail(function(e) {
+                  Alertify.alert(
+                    gettext('Debugger Target Initialization Error'),
+                    e.responseJSON.errormsg
+                  );
                 });
               } else {
                 // If the debugging is started again then we should only set the
@@ -806,13 +806,13 @@ define([
                   data: {
                     'data': JSON.stringify(args_value_list),
                   },
-                  success: function() {},
-                  error: function(e) {
-                    Alertify.alert(
-                      gettext('Debugger Listener Startup Error'),
-                      e.responseJSON.errormsg
-                    );
-                  },
+                })
+                .done(function() {})
+                .fail(function(e) {
+                  Alertify.alert(
+                    gettext('Debugger Listener Startup Error'),
+                    e.responseJSON.errormsg
+                  );
                 });
 
                 // Set the new input arguments given by the user during debugging
@@ -828,13 +828,13 @@ define([
                   data: {
                     'data': JSON.stringify(sqlite_func_args_list),
                   },
-                  success: function() {},
-                  error: function() {
-                    Alertify.alert(
-                      gettext('Debugger Error'),
-                      gettext('Unable to set the arguments on the server')
-                    );
-                  },
+                })
+                .done(function() {})
+                .fail(function() {
+                  Alertify.alert(
+                    gettext('Debugger Error'),
+                    gettext('Unable to set the arguments on the server')
+                  );
                 });
 
               }
diff --git a/web/pgadmin/tools/debugger/static/js/direct.js b/web/pgadmin/tools/debugger/static/js/direct.js
index f7f8edfe..4151a924 100644
--- a/web/pgadmin/tools/debugger/static/js/direct.js
+++ b/web/pgadmin/tools/debugger/static/js/direct.js
@@ -45,17 +45,17 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              // Breakpoint has been set by the user
-            }
-          },
-          error: function() {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while setting debugging breakpoint.')
-            );
-          },
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            // Breakpoint has been set by the user
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while setting debugging breakpoint.')
+          );
         });
       },
 
@@ -107,22 +107,22 @@ define([
           url: baseUrl,
           method: 'GET',
           async: false,
-          success: function(res) {
-            if (res.data.status === 'Success') {
-              result = res.data.result;
-            } else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while fetching breakpoint information.')
-              );
-            }
-          },
-          error: function() {
+        })
+        .done(function(res) {
+          if (res.data.status === 'Success') {
+            result = res.data.result;
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while fetching breakpoint information.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while fetching breakpoint information.')
+          );
         });
 
         return result;
@@ -140,23 +140,23 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status === 'Success') {
-              // If status is Success then find the port number to attach the executer.
-              self.execute_query(trans_id);
-            } else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while starting debugging session.')
-              );
-            }
-          },
-          error: function() {
+        })
+        .done(function(res) {
+          if (res.data.status === 'Success') {
+            // If status is Success then find the port number to attach the executer.
+            self.execute_query(trans_id);
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while starting debugging session.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while starting debugging session.')
+          );
         });
       },
 
@@ -172,38 +172,38 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status === 'Success') {
-              // set the return code to the code editor text area
-              if (
-                res.data.result[0].src != null &&
-                res.data.result[0].linenumber != null
-              ) {
-                pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
-                self.active_line_no = (res.data.result[0].linenumber - 2);
-                pgTools.DirectDebug.editor.addLineClass(
-                  (res.data.result[0].linenumber - 2), 'wrap',
-                  'CodeMirror-activeline-background'
-                );
-              }
-              // Call function to create and update local variables ....
-              self.GetStackInformation(trans_id);
-              if (pgTools.DirectDebug.debug_type) {
-                self.poll_end_execution_result(trans_id);
-              }
-            } else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while executing requested debugging information.')
+        })
+        .done(function(res) {
+          if (res.data.status === 'Success') {
+            // set the return code to the code editor text area
+            if (
+              res.data.result[0].src != null &&
+              res.data.result[0].linenumber != null
+            ) {
+              pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
+              self.active_line_no = (res.data.result[0].linenumber - 2);
+              pgTools.DirectDebug.editor.addLineClass(
+                (res.data.result[0].linenumber - 2), 'wrap',
+                'CodeMirror-activeline-background'
               );
             }
-          },
-          error: function() {
+            // Call function to create and update local variables ....
+            self.GetStackInformation(trans_id);
+            if (pgTools.DirectDebug.debug_type) {
+              self.poll_end_execution_result(trans_id);
+            }
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing requested debugging information.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while executing requested debugging information.')
+          );
         });
       },
 
@@ -220,32 +220,32 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status === 'Success') {
-              // Call function to create and update local variables
-              self.AddLocalVariables(res.data.result);
-              self.AddParameters(res.data.result);
-              // If debug function is restarted then again start listener to
-              // read the updated messages.
-              if (pgTools.DirectDebug.debug_restarted) {
-                if (pgTools.DirectDebug.debug_type) {
-                  self.poll_end_execution_result(trans_id);
-                }
-                pgTools.DirectDebug.debug_restarted = false;
+        })
+        .done(function(res) {
+          if (res.data.status === 'Success') {
+            // Call function to create and update local variables
+            self.AddLocalVariables(res.data.result);
+            self.AddParameters(res.data.result);
+            // If debug function is restarted then again start listener to
+            // read the updated messages.
+            if (pgTools.DirectDebug.debug_restarted) {
+              if (pgTools.DirectDebug.debug_type) {
+                self.poll_end_execution_result(trans_id);
               }
-            } else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while fetching variable information.')
-              );
+              pgTools.DirectDebug.debug_restarted = false;
             }
-          },
-          error: function() {
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while fetching variable information.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while fetching variable information.')
+          );
         });
       },
 
@@ -262,24 +262,24 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status === 'Success') {
-              // Call function to create and update stack information
-              self.AddStackInformation(res.data.result);
-              self.GetLocalVariables(pgTools.DirectDebug.trans_id);
-            } else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while fetching stack information.')
-              );
-            }
-          },
-          error: function() {
+        })
+        .done(function(res) {
+          if (res.data.status === 'Success') {
+            // Call function to create and update stack information
+            self.AddStackInformation(res.data.result);
+            self.GetLocalVariables(pgTools.DirectDebug.trans_id);
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while fetching stack information.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while fetching stack information.')
+          );
         });
       },
 
@@ -323,105 +323,105 @@ define([
                 // set cursor to progress before every poll.
                 $('.debugger-container').addClass('show_progress');
               },
-              success: function(res) {
-                // remove progress cursor
-                $('.debugger-container').removeClass('show_progress');
-
-                if (res.data.status === 'Success') {
-                  // If no result then poll again to wait for results.
-                  if (res.data.result == null || res.data.result.length == 0) {
-                    self.poll_result(trans_id);
-                  } else {
-                    if (res.data.result[0].src != undefined || res.data.result[0].src != null) {
-                      pgTools.DirectDebug.polling_timeout_idle = false;
-                      pgTools.DirectDebug.docker.finishLoading(50);
-                      pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
-                      self.UpdateBreakpoint(trans_id);
-                      pgTools.DirectDebug.editor.removeLineClass(
-                        self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
-                      );
-                      pgTools.DirectDebug.editor.addLineClass(
-                        (res.data.result[0].linenumber - 2),
-                        'wrap', 'CodeMirror-activeline-background'
-                      );
-                      self.active_line_no = (res.data.result[0].linenumber - 2);
-                      // Update the stack, local variables and parameters information
-                      self.GetStackInformation(trans_id);
-
-                    } else if (!pgTools.DirectDebug.debug_type && !pgTools.DirectDebug.first_time_indirect_debug) {
-                      pgTools.DirectDebug.docker.finishLoading(50);
-                      if (self.active_line_no != undefined) {
-                        pgTools.DirectDebug.editor.removeLineClass(
-                          self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
-                        );
-                      }
-                      self.clear_all_breakpoint(trans_id);
-                      self.execute_query(trans_id);
-                      pgTools.DirectDebug.first_time_indirect_debug = true;
-                      pgTools.DirectDebug.polling_timeout_idle = false;
-                    } else {
-                      pgTools.DirectDebug.polling_timeout_idle = false;
-                      pgTools.DirectDebug.docker.finishLoading(50);
-                      // If the source is really changed then only update the breakpoint information
-                      if (res.data.result[0].src != pgTools.DirectDebug.editor.getValue()) {
-                        pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
-                        self.UpdateBreakpoint(trans_id);
-                      }
+            })
+            .done(function(res) {
+              // remove progress cursor
+              $('.debugger-container').removeClass('show_progress');
+
+              if (res.data.status === 'Success') {
+                // If no result then poll again to wait for results.
+                if (res.data.result == null || res.data.result.length == 0) {
+                  self.poll_result(trans_id);
+                } else {
+                  if (res.data.result[0].src != undefined || res.data.result[0].src != null) {
+                    pgTools.DirectDebug.polling_timeout_idle = false;
+                    pgTools.DirectDebug.docker.finishLoading(50);
+                    pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
+                    self.UpdateBreakpoint(trans_id);
+                    pgTools.DirectDebug.editor.removeLineClass(
+                      self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
+                    );
+                    pgTools.DirectDebug.editor.addLineClass(
+                      (res.data.result[0].linenumber - 2),
+                      'wrap', 'CodeMirror-activeline-background'
+                    );
+                    self.active_line_no = (res.data.result[0].linenumber - 2);
+                    // Update the stack, local variables and parameters information
+                    self.GetStackInformation(trans_id);
 
+                  } else if (!pgTools.DirectDebug.debug_type && !pgTools.DirectDebug.first_time_indirect_debug) {
+                    pgTools.DirectDebug.docker.finishLoading(50);
+                    if (self.active_line_no != undefined) {
                       pgTools.DirectDebug.editor.removeLineClass(
                         self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
                       );
-                      pgTools.DirectDebug.editor.addLineClass(
-                        (res.data.result[0].linenumber - 2),
-                        'wrap', 'CodeMirror-activeline-background'
-                      );
-                      self.active_line_no = (res.data.result[0].linenumber - 2);
-
-                      // Update the stack, local variables and parameters information
-                      self.GetStackInformation(trans_id);
+                    }
+                    self.clear_all_breakpoint(trans_id);
+                    self.execute_query(trans_id);
+                    pgTools.DirectDebug.first_time_indirect_debug = true;
+                    pgTools.DirectDebug.polling_timeout_idle = false;
+                  } else {
+                    pgTools.DirectDebug.polling_timeout_idle = false;
+                    pgTools.DirectDebug.docker.finishLoading(50);
+                    // If the source is really changed then only update the breakpoint information
+                    if (res.data.result[0].src != pgTools.DirectDebug.editor.getValue()) {
+                      pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
+                      self.UpdateBreakpoint(trans_id);
                     }
 
-                    // Enable all the buttons as we got the results
-                    self.enable('stop', true);
-                    self.enable('step_over', true);
-                    self.enable('step_into', true);
-                    self.enable('continue', true);
-                    self.enable('toggle_breakpoint', true);
-                    self.enable('clear_all_breakpoints', true);
-                  }
-                } else if (res.data.status === 'Busy') {
-                  pgTools.DirectDebug.polling_timeout_idle = true;
-                  // If status is Busy then poll the result by recursive call to the poll function
-                  if (!pgTools.DirectDebug.debug_type) {
-                    pgTools.DirectDebug.docker.startLoading(
-                      gettext('Waiting for another session to invoke the target...')
+                    pgTools.DirectDebug.editor.removeLineClass(
+                      self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
                     );
+                    pgTools.DirectDebug.editor.addLineClass(
+                      (res.data.result[0].linenumber - 2),
+                      'wrap', 'CodeMirror-activeline-background'
+                    );
+                    self.active_line_no = (res.data.result[0].linenumber - 2);
 
-                    // As we are waiting for another session to invoke the target,disable all the buttons
-                    self.enable('stop', false);
-                    self.enable('step_over', false);
-                    self.enable('step_into', false);
-                    self.enable('continue', false);
-                    self.enable('toggle_breakpoint', false);
-                    self.enable('clear_all_breakpoints', false);
-                    pgTools.DirectDebug.first_time_indirect_debug = false;
-                    self.poll_result(trans_id);
-                  } else {
-                    self.poll_result(trans_id);
+                    // Update the stack, local variables and parameters information
+                    self.GetStackInformation(trans_id);
                   }
-                } else if (res.data.status === 'NotConnected') {
-                  Alertify.alert(
-                    gettext('Debugger Error'),
-                    gettext('Error while polling result.')
+
+                  // Enable all the buttons as we got the results
+                  self.enable('stop', true);
+                  self.enable('step_over', true);
+                  self.enable('step_into', true);
+                  self.enable('continue', true);
+                  self.enable('toggle_breakpoint', true);
+                  self.enable('clear_all_breakpoints', true);
+                }
+              } else if (res.data.status === 'Busy') {
+                pgTools.DirectDebug.polling_timeout_idle = true;
+                // If status is Busy then poll the result by recursive call to the poll function
+                if (!pgTools.DirectDebug.debug_type) {
+                  pgTools.DirectDebug.docker.startLoading(
+                    gettext('Waiting for another session to invoke the target...')
                   );
+
+                  // As we are waiting for another session to invoke the target,disable all the buttons
+                  self.enable('stop', false);
+                  self.enable('step_over', false);
+                  self.enable('step_into', false);
+                  self.enable('continue', false);
+                  self.enable('toggle_breakpoint', false);
+                  self.enable('clear_all_breakpoints', false);
+                  pgTools.DirectDebug.first_time_indirect_debug = false;
+                  self.poll_result(trans_id);
+                } else {
+                  self.poll_result(trans_id);
                 }
-              },
-              error: function() {
+              } else if (res.data.status === 'NotConnected') {
                 Alertify.alert(
                   gettext('Debugger Error'),
                   gettext('Error while polling result.')
                 );
-              },
+              }
+            })
+            .fail(function() {
+              Alertify.alert(
+                gettext('Debugger Error'),
+                gettext('Error while polling result.')
+              );
             });
           }, poll_timeout);
 
@@ -484,17 +484,51 @@ define([
             $.ajax({
               url: baseUrl,
               method: 'GET',
-              success: function(res) {
-                if (res.data.status === 'Success') {
-                  if (res.data.result == undefined) {
-                    /*
-                     "result" is undefined only in case of EDB procedure.
-                     As Once the EDB procedure execution is completed then we are
-                     not getting any result so we need ignore the result.
-                    */
+            })
+            .done(function(res) {
+              if (res.data.status === 'Success') {
+                if (res.data.result == undefined) {
+                  /*
+                   "result" is undefined only in case of EDB procedure.
+                   As Once the EDB procedure execution is completed then we are
+                   not getting any result so we need ignore the result.
+                  */
+                  pgTools.DirectDebug.editor.removeLineClass(
+                    self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
+                  );
+                  pgTools.DirectDebug.direct_execution_completed = true;
+                  pgTools.DirectDebug.polling_timeout_idle = true;
+
+                  //Set the alertify message to inform the user that execution is completed.
+                  Alertify.success(res.info, 3);
+
+                  // Update the message tab of the debugger
+                  if (res.data.status_message) {
+                    self.update_messages(res.data.status_message);
+                  }
+
+                  // remove progress cursor
+                  $('.debugger-container').removeClass('show_progress');
+
+                  // Execution completed so disable the buttons other than
+                  // "Continue/Start" button because user can still
+                  // start the same execution again.
+                  self.enable('stop', false);
+                  self.enable('step_over', false);
+                  self.enable('step_into', false);
+                  self.enable('toggle_breakpoint', false);
+                  self.enable('clear_all_breakpoints', false);
+                  self.enable('continue', true);
+                  // Stop further polling
+                  pgTools.DirectDebug.is_polling_required = false;
+                } else {
+                  // Call function to create and update local variables ....
+                  if (res.data.result != null) {
                     pgTools.DirectDebug.editor.removeLineClass(
                       self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
                     );
+                    self.AddResults(res.data.col_info, res.data.result);
+                    pgTools.DirectDebug.results_panel.focus();
                     pgTools.DirectDebug.direct_execution_completed = true;
                     pgTools.DirectDebug.polling_timeout_idle = true;
 
@@ -518,104 +552,70 @@ define([
                     self.enable('toggle_breakpoint', false);
                     self.enable('clear_all_breakpoints', false);
                     self.enable('continue', true);
-                    // Stop further polling
-                    pgTools.DirectDebug.is_polling_required = false;
-                  } else {
-                    // Call function to create and update local variables ....
-                    if (res.data.result != null) {
-                      pgTools.DirectDebug.editor.removeLineClass(
-                        self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
-                      );
-                      self.AddResults(res.data.col_info, res.data.result);
-                      pgTools.DirectDebug.results_panel.focus();
-                      pgTools.DirectDebug.direct_execution_completed = true;
-                      pgTools.DirectDebug.polling_timeout_idle = true;
-
-                      //Set the alertify message to inform the user that execution is completed.
-                      Alertify.success(res.info, 3);
-
-                      // Update the message tab of the debugger
-                      if (res.data.status_message) {
-                        self.update_messages(res.data.status_message);
-                      }
-
-                      // remove progress cursor
-                      $('.debugger-container').removeClass('show_progress');
-
-                      // Execution completed so disable the buttons other than
-                      // "Continue/Start" button because user can still
-                      // start the same execution again.
-                      self.enable('stop', false);
-                      self.enable('step_over', false);
-                      self.enable('step_into', false);
-                      self.enable('toggle_breakpoint', false);
-                      self.enable('clear_all_breakpoints', false);
-                      self.enable('continue', true);
-
-                      // Stop further pooling
-                      pgTools.DirectDebug.is_polling_required = false;
-                    }
-                  }
-                } else if (res.data.status === 'Busy') {
-                  // If status is Busy then poll the result by recursive call to
-                  // the poll function
-                  self.poll_end_execution_result(trans_id);
-                  // Update the message tab of the debugger
-                  if (res.data.status_message) {
-                    self.update_messages(res.data.status_message);
-                  }
-                } else if (res.data.status === 'NotConnected') {
-                  Alertify.alert(
-                    gettext('Debugger poll end execution error'),
-                    res.data.result
-                  );
-                } else if (res.data.status === 'ERROR') {
-                  pgTools.DirectDebug.direct_execution_completed = true;
-                  pgTools.DirectDebug.editor.removeLineClass(
-                    self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
-                  );
 
-                  //Set the Alertify message to inform the user that execution is
-                  // completed with error.
-                  if (!pgTools.DirectDebug.is_user_aborted_debugging) {
-                    Alertify.error(res.info, 3);
+                    // Stop further pooling
+                    pgTools.DirectDebug.is_polling_required = false;
                   }
+                }
+              } else if (res.data.status === 'Busy') {
+                // If status is Busy then poll the result by recursive call to
+                // the poll function
+                self.poll_end_execution_result(trans_id);
+                // Update the message tab of the debugger
+                if (res.data.status_message) {
+                  self.update_messages(res.data.status_message);
+                }
+              } else if (res.data.status === 'NotConnected') {
+                Alertify.alert(
+                  gettext('Debugger poll end execution error'),
+                  res.data.result
+                );
+              } else if (res.data.status === 'ERROR') {
+                pgTools.DirectDebug.direct_execution_completed = true;
+                pgTools.DirectDebug.editor.removeLineClass(
+                  self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
+                );
 
-                  // Update the message tab of the debugger
-                  if (res.data.status_message) {
-                    self.update_messages(res.data.status_message);
-                  }
+                //Set the Alertify message to inform the user that execution is
+                // completed with error.
+                if (!pgTools.DirectDebug.is_user_aborted_debugging) {
+                  Alertify.error(res.info, 3);
+                }
 
-                  pgTools.DirectDebug.messages_panel.focus();
+                // Update the message tab of the debugger
+                if (res.data.status_message) {
+                  self.update_messages(res.data.status_message);
+                }
 
-                  // remove progress cursor
-                  $('.debugger-container').removeClass('show_progress');
+                pgTools.DirectDebug.messages_panel.focus();
 
-                  // Execution completed so disable the buttons other than
-                  // "Continue/Start" button because user can still start the
-                  // same execution again.
-                  self.enable('stop', false);
-                  self.enable('step_over', false);
-                  self.enable('step_into', false);
-                  self.enable('toggle_breakpoint', false);
-                  self.enable('clear_all_breakpoints', false);
-                  // If debugging is stopped by user then do not enable
-                  // continue/restart button
-                  if (!pgTools.DirectDebug.is_user_aborted_debugging) {
-                    self.enable('continue', true);
-                    pgTools.DirectDebug.is_user_aborted_debugging = false;
-                  }
+                // remove progress cursor
+                $('.debugger-container').removeClass('show_progress');
 
-                  // Stop further pooling
-                  pgTools.DirectDebug.is_polling_required = false;
+                // Execution completed so disable the buttons other than
+                // "Continue/Start" button because user can still start the
+                // same execution again.
+                self.enable('stop', false);
+                self.enable('step_over', false);
+                self.enable('step_into', false);
+                self.enable('toggle_breakpoint', false);
+                self.enable('clear_all_breakpoints', false);
+                // If debugging is stopped by user then do not enable
+                // continue/restart button
+                if (!pgTools.DirectDebug.is_user_aborted_debugging) {
+                  self.enable('continue', true);
+                  pgTools.DirectDebug.is_user_aborted_debugging = false;
                 }
-              },
-              error: function() {
-                Alertify.alert(
-                  gettext('Debugger Error'),
-                  gettext('Error while polling result.')
-                );
-              },
+
+                // Stop further pooling
+                pgTools.DirectDebug.is_polling_required = false;
+              }
+            })
+            .fail(function() {
+              Alertify.alert(
+                gettext('Debugger Error'),
+                gettext('Error while polling result.')
+              );
             });
           }, poll_end_timeout);
 
@@ -642,62 +642,62 @@ define([
 
         $.ajax({
           url: baseUrl,
-          success: function(res) {
-            // Restart the same function debugging with previous arguments
-            var restart_dbg = res.data.restart_debug ? 1 : 0;
-
-            // Start pooling again
-            pgTools.DirectDebug.polling_timeout_idle = false;
-            pgTools.DirectDebug.is_polling_required = true;
-            self.poll_end_execution_result(trans_id);
-            self.poll_result(trans_id);
-
-            if (restart_dbg) {
-              pgTools.DirectDebug.debug_restarted = true;
-            }
+        })
+        .done(function(res) {
+          // Restart the same function debugging with previous arguments
+          var restart_dbg = res.data.restart_debug ? 1 : 0;
+
+          // Start pooling again
+          pgTools.DirectDebug.polling_timeout_idle = false;
+          pgTools.DirectDebug.is_polling_required = true;
+          self.poll_end_execution_result(trans_id);
+          self.poll_result(trans_id);
+
+          if (restart_dbg) {
+            pgTools.DirectDebug.debug_restarted = true;
+          }
 
-            /*
-             Need to check if restart debugging really require to open the input
-             dialog? If yes then we will get the previous arguments from database
-             and populate the input dialog, If no then we should directly start the
-             listener.
-            */
-            if (res.data.result.require_input) {
-              debug_function_again(res.data.result, restart_dbg);
-            } else {
-              // Debugging of void function is started again so we need to start
-              // the listener again
-              var baseUrl = url_for('debugger.start_listener', {
-                'trans_id': trans_id,
-              });
+          /*
+           Need to check if restart debugging really require to open the input
+           dialog? If yes then we will get the previous arguments from database
+           and populate the input dialog, If no then we should directly start the
+           listener.
+          */
+          if (res.data.result.require_input) {
+            debug_function_again(res.data.result, restart_dbg);
+          } else {
+            // Debugging of void function is started again so we need to start
+            // the listener again
+            var baseUrl = url_for('debugger.start_listener', {
+              'trans_id': trans_id,
+            });
 
-              $.ajax({
-                url: baseUrl,
-                method: 'GET',
-                success: function() {
-                  if (pgTools.DirectDebug.debug_type) {
-                    self.poll_end_execution_result(trans_id);
-                  }
-                },
-                error: function() {
-                  Alertify.alert(
-                    gettext('Debugger Error'),
-                    gettext('Error while polling result.')
-                  );
-                },
-              });
-            }
-          },
-          error: function(xhr) {
-            try {
-              var err = JSON.parse(xhr.responseText);
-              if (err.success == 0) {
-                Alertify.alert(gettext('Debugger Error'), err.errormsg);
+            $.ajax({
+              url: baseUrl,
+              method: 'GET',
+            })
+            .done(function() {
+              if (pgTools.DirectDebug.debug_type) {
+                self.poll_end_execution_result(trans_id);
               }
-            } catch (e) {
-              console.warn(e.stack || e);
+            })
+            .fail(function() {
+              Alertify.alert(
+                gettext('Debugger Error'),
+                gettext('Error while polling result.')
+              );
+            });
+          }
+        })
+        .fail(function(xhr) {
+          try {
+            var err = JSON.parse(xhr.responseText);
+            if (err.success == 0) {
+              Alertify.alert(gettext('Debugger Error'), err.errormsg);
             }
-          },
+          } catch (e) {
+            console.warn(e.stack || e);
+          }
         });
       },
 
@@ -724,22 +724,22 @@ define([
           $.ajax({
             url: baseUrl,
             method: 'GET',
-            success: function(res) {
-              if (res.data.status) {
-                self.poll_result(trans_id);
-              } else {
-                Alertify.alert(
-                  gettext('Debugger Error'),
-                  gettext('Error while executing continue in debugging session.')
-                );
-              }
-            },
-            error: function() {
+          })
+          .done(function(res) {
+            if (res.data.status) {
+              self.poll_result(trans_id);
+            } else {
               Alertify.alert(
                 gettext('Debugger Error'),
                 gettext('Error while executing continue in debugging session.')
               );
-            },
+            }
+          })
+          .fail(function() {
+            Alertify.alert(
+              gettext('Debugger Error'),
+              gettext('Error while executing continue in debugging session.')
+            );
           });
         }
       },
@@ -761,22 +761,22 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              self.poll_result(trans_id);
-            } else {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while executing step over in debugging session.')
-              );
-            }
-          },
-          error: function() {
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            self.poll_result(trans_id);
+          } else {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing step over in debugging session.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while executing step over in debugging session.')
+          );
         });
       },
 
@@ -797,22 +797,22 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              self.poll_result(trans_id);
-            } else {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while executing step into in debugging session.')
-              );
-            }
-          },
-          error: function() {
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            self.poll_result(trans_id);
+          } else {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing step into in debugging session.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while executing step into in debugging session.')
+          );
         });
       },
 
@@ -834,38 +834,38 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              // Call function to create and update local variables ....
-              pgTools.DirectDebug.editor.removeLineClass(
-                self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
-              );
-              pgTools.DirectDebug.direct_execution_completed = true;
-              pgTools.DirectDebug.is_user_aborted_debugging = true;
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            // Call function to create and update local variables ....
+            pgTools.DirectDebug.editor.removeLineClass(
+              self.active_line_no, 'wrap', 'CodeMirror-activeline-background'
+            );
+            pgTools.DirectDebug.direct_execution_completed = true;
+            pgTools.DirectDebug.is_user_aborted_debugging = true;
 
-              // Stop further pooling
-              pgTools.DirectDebug.is_polling_required = false;
+            // Stop further pooling
+            pgTools.DirectDebug.is_polling_required = false;
 
-              // Restarting debugging in the same transaction do not work
-              // We will give same behaviour as pgAdmin3 and disable all buttons
-              self.enable('continue', false);
+            // Restarting debugging in the same transaction do not work
+            // We will give same behaviour as pgAdmin3 and disable all buttons
+            self.enable('continue', false);
 
-              // Set the Alertify message to inform the user that execution
-              // is completed.
-              Alertify.success(res.info, 3);
-            } else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while executing stop in debugging session.')
-              );
-            }
-          },
-          error: function() {
+            // Set the Alertify message to inform the user that execution
+            // is completed.
+            Alertify.success(res.info, 3);
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while executing stop in debugging session.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while executing stop in debugging session.')
+          );
         });
       },
 
@@ -901,40 +901,40 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              // Call function to create and update local variables ....
-              var info = pgTools.DirectDebug.editor.lineInfo(self.active_line_no);
-
-              if (info.gutterMarkers != undefined) {
-                pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, 'breakpoints', null);
-              } else {
-                pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, 'breakpoints', function() {
-                  var marker = document.createElement('div');
-                  marker.style.color = '#822';
-                  marker.innerHTML = '●';
-                  return marker;
-                }());
-              }
-              self.enable('stop', true);
-              self.enable('step_over', true);
-              self.enable('step_into', true);
-              self.enable('toggle_breakpoint', true);
-              self.enable('clear_all_breakpoints', true);
-              self.enable('continue', true);
-            } else if (res.data.status === 'NotConnected') {
-              Alertify.alert(
-                gettext('Debugger Error'),
-                gettext('Error while toggling breakpoint.')
-              );
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            // Call function to create and update local variables ....
+            var info = pgTools.DirectDebug.editor.lineInfo(self.active_line_no);
+
+            if (info.gutterMarkers != undefined) {
+              pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, 'breakpoints', null);
+            } else {
+              pgTools.DirectDebug.editor.setGutterMarker(self.active_line_no, 'breakpoints', function() {
+                var marker = document.createElement('div');
+                marker.style.color = '#822';
+                marker.innerHTML = '●';
+                return marker;
+              }());
             }
-          },
-          error: function() {
+            self.enable('stop', true);
+            self.enable('step_over', true);
+            self.enable('step_into', true);
+            self.enable('toggle_breakpoint', true);
+            self.enable('clear_all_breakpoints', true);
+            self.enable('continue', true);
+          } else if (res.data.status === 'NotConnected') {
             Alertify.alert(
               gettext('Debugger Error'),
               gettext('Error while toggling breakpoint.')
             );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while toggling breakpoint.')
+          );
         });
       },
 
@@ -972,31 +972,31 @@ define([
           data: {
             'breakpoint_list': breakpoint_list.join(),
           },
-          success: function(res) {
-            if (res.data.status) {
-              for (var i = 0; i < breakpoint_list.length; i++) {
-                var info = pgTools.DirectDebug.editor.lineInfo((breakpoint_list[i] - 1));
-
-                if (info) {
-                  if (info.gutterMarkers != undefined) {
-                    pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), 'breakpoints', null);
-                  }
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            for (var i = 0; i < breakpoint_list.length; i++) {
+              var info = pgTools.DirectDebug.editor.lineInfo((breakpoint_list[i] - 1));
+
+              if (info) {
+                if (info.gutterMarkers != undefined) {
+                  pgTools.DirectDebug.editor.setGutterMarker((breakpoint_list[i] - 1), 'breakpoints', null);
                 }
               }
             }
-            self.enable('stop', true);
-            self.enable('step_over', true);
-            self.enable('step_into', true);
-            self.enable('toggle_breakpoint', true);
-            self.enable('clear_all_breakpoints', true);
-            self.enable('continue', true);
-          },
-          error: function() {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while clearing all breakpoint.')
-            );
-          },
+          }
+          self.enable('stop', true);
+          self.enable('step_over', true);
+          self.enable('step_into', true);
+          self.enable('toggle_breakpoint', true);
+          self.enable('clear_all_breakpoints', true);
+          self.enable('continue', true);
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while clearing all breakpoint.')
+          );
         });
       },
 
@@ -1332,24 +1332,24 @@ define([
           data: {
             'data': JSON.stringify(name_value_list),
           },
-          success: function(res) {
-            if (res.data.status) {
-              // Get the updated variables value
-              self.GetLocalVariables(pgTools.DirectDebug.trans_id);
-              // Show the message to the user that deposit value is success or failure
-              if (res.data.result) {
-                Alertify.success(res.data.info, 3);
-              } else {
-                Alertify.error(res.data.info, 3);
-              }
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            // Get the updated variables value
+            self.GetLocalVariables(pgTools.DirectDebug.trans_id);
+            // Show the message to the user that deposit value is success or failure
+            if (res.data.result) {
+              Alertify.success(res.data.info, 3);
+            } else {
+              Alertify.error(res.data.info, 3);
             }
-          },
-          error: function() {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while depositing variable value.')
-            );
-          },
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while depositing variable value.')
+          );
         });
       },
 
@@ -1364,26 +1364,26 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
-              self.UpdateBreakpoint(pgTools.DirectDebug.trans_id);
-              // active_line_no =
-              //   self.active_line_no = (res.data.result[0].linenumber - 2);
-              pgTools.DirectDebug.editor.addLineClass(
-                (res.data.result[0].linenumber - 2), 'wrap',
-                'CodeMirror-activeline-background'
-              );
-              // Call function to create and update local variables ....
-              self.GetLocalVariables(pgTools.DirectDebug.trans_id);
-            }
-          },
-          error: function() {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while selecting frame.')
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            pgTools.DirectDebug.editor.setValue(res.data.result[0].src);
+            self.UpdateBreakpoint(pgTools.DirectDebug.trans_id);
+            // active_line_no =
+            //   self.active_line_no = (res.data.result[0].linenumber - 2);
+            pgTools.DirectDebug.editor.addLineClass(
+              (res.data.result[0].linenumber - 2), 'wrap',
+              'CodeMirror-activeline-background'
             );
-          },
+            // Call function to create and update local variables ....
+            self.GetLocalVariables(pgTools.DirectDebug.trans_id);
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while selecting frame.')
+          );
         });
       },
     }
@@ -1597,18 +1597,18 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              self.intializePanels();
-              controller.poll_result(trans_id);
-            }
-          },
-          error: function() {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while starting debugging listener.')
-            );
-          },
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            self.intializePanels();
+            controller.poll_result(trans_id);
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while starting debugging listener.')
+          );
         });
       } else if (trans_id != undefined && debug_type) {
         // Make ajax call to execute the and start the target for execution
@@ -1619,17 +1619,17 @@ define([
         $.ajax({
           url: baseUrl,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              self.messages(trans_id);
-            }
-          },
-          error: function() {
-            Alertify.alert(
-              gettext('Debugger Error'),
-              gettext('Error while starting debugging listener.')
-            );
-          },
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            self.messages(trans_id);
+          }
+        })
+        .fail(function() {
+          Alertify.alert(
+            gettext('Debugger Error'),
+            gettext('Error while starting debugging listener.')
+          );
         });
       } else
         this.intializePanels();
@@ -1647,28 +1647,28 @@ define([
       $.ajax({
         url: baseUrl,
         method: 'GET',
-        success: function(res) {
-          if (res.data.status === 'Success') {
-            self.intializePanels();
-            // If status is Success then find the port number to attach the executer.
-            //self.start_execution(trans_id, res.data.result);
-            controller.start_execution(trans_id, res.data.result);
-          } else if (res.data.status === 'Busy') {
-            // If status is Busy then poll the result by recursive call to the poll function
-            self.messages(trans_id);
-          } else if (res.data.status === 'NotConnected') {
-            Alertify.alert(
-              gettext('Not connected to server or connection with the server has been closed.'),
-              res.data.result
-            );
-          }
-        },
-        error: function() {
+      })
+      .done(function(res) {
+        if (res.data.status === 'Success') {
+          self.intializePanels();
+          // If status is Success then find the port number to attach the executer.
+          //self.start_execution(trans_id, res.data.result);
+          controller.start_execution(trans_id, res.data.result);
+        } else if (res.data.status === 'Busy') {
+          // If status is Busy then poll the result by recursive call to the poll function
+          self.messages(trans_id);
+        } else if (res.data.status === 'NotConnected') {
           Alertify.alert(
-            gettext('Debugger Error'),
-            gettext('Error while fetching messages information.')
+            gettext('Not connected to server or connection with the server has been closed.'),
+            res.data.result
           );
-        },
+        }
+      })
+      .fail(function() {
+        Alertify.alert(
+          gettext('Debugger Error'),
+          gettext('Error while fetching messages information.')
+        );
       });
 
     },
diff --git a/web/pgadmin/tools/import_export/static/js/import_export.js b/web/pgadmin/tools/import_export/static/js/import_export.js
index 5c73537e..7d40629f 100644
--- a/web/pgadmin/tools/import_export/static/js/import_export.js
+++ b/web/pgadmin/tools/import_export/static/js/import_export.js
@@ -526,23 +526,23 @@ Backform, commonUtils, supportedNodes
                   data: {
                     'data': JSON.stringify(this.view.model.toJSON()),
                   },
-                  success: function(res) {
-                    if (res.success) {
-                      Alertify.success(gettext('Import/export job created.'), 5);
-                      pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
-                    }
-                  },
-                  error: function(xhr) {
-                    try {
-                      var err = JSON.parse(xhr.responseText);
-                      Alertify.alert(
-                        gettext('Import/export job failed.'),
-                        err.errormsg
-                      );
-                    } catch (e) {
-                      console.warn(e.stack || e);
-                    }
-                  },
+                })
+                .done(function(res) {
+                  if (res.success) {
+                    Alertify.success(gettext('Import/export job created.'), 5);
+                    pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
+                  }
+                })
+                .fail(function(xhr) {
+                  try {
+                    var err = JSON.parse(xhr.responseText);
+                    Alertify.alert(
+                      gettext('Import/export job failed.'),
+                      err.errormsg
+                    );
+                  } catch (e) {
+                    console.warn(e.stack || e);
+                  }
                 });
               }
             },
diff --git a/web/pgadmin/tools/maintenance/static/js/maintenance.js b/web/pgadmin/tools/maintenance/static/js/maintenance.js
index df05c3d5..a9c70752 100644
--- a/web/pgadmin/tools/maintenance/static/js/maintenance.js
+++ b/web/pgadmin/tools/maintenance/static/js/maintenance.js
@@ -385,20 +385,20 @@ define([
                   data: {
                     'data': JSON.stringify(this.view.model.toJSON()),
                   },
-                  success: function(res) {
-                    if (res.data && res.data.status) {
-                      //Do nothing as we are creating the job and exiting from the main dialog
-                      Alertify.success(res.data.info);
-                      pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
-                    } else {
-                      Alertify.error(res.data.errmsg);
-                    }
-                  },
-                  error: function() {
-                    Alertify.alert(
-                      gettext('Maintenance job creation failed.')
-                    );
-                  },
+                })
+                .done(function(res) {
+                  if (res.data && res.data.status) {
+                    //Do nothing as we are creating the job and exiting from the main dialog
+                    Alertify.success(res.data.info);
+                    pgBrowser.Events.trigger('pgadmin-bgprocess:created', self);
+                  } else {
+                    Alertify.error(res.data.errmsg);
+                  }
+                })
+                .fail(function() {
+                  Alertify.alert(
+                    gettext('Maintenance job creation failed.')
+                  );
                 });
               }
             },
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 6d4eb31e..1316c7be 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -427,73 +427,73 @@ define('tools.querytool', [
               method: 'POST',
               contentType: 'application/json',
               data: JSON.stringify(self.data),
-              success: function(res) {
-                var result = [];
-
-                _.each(res.data.result, function(obj, key) {
-                  result.push({
-                    text: key,
-                    type: obj.object_type,
-                    render: self.hint_render,
-                  });
+            })
+            .done(function(res) {
+              var result = [];
+
+              _.each(res.data.result, function(obj, key) {
+                result.push({
+                  text: key,
+                  type: obj.object_type,
+                  render: self.hint_render,
                 });
+              });
 
-                // Sort function to sort the suggestion's alphabetically.
-                result.sort(function(a, b) {
-                  var textA = a.text.toLowerCase(),
-                    textB = b.text.toLowerCase();
-                  if (textA < textB) //sort string ascending
-                    return -1;
-                  if (textA > textB)
-                    return 1;
-                  return 0; //default return value (no sorting)
-                });
+              // Sort function to sort the suggestion's alphabetically.
+              result.sort(function(a, b) {
+                var textA = a.text.toLowerCase(),
+                  textB = b.text.toLowerCase();
+                if (textA < textB) //sort string ascending
+                  return -1;
+                if (textA > textB)
+                  return 1;
+                return 0; //default return value (no sorting)
+              });
 
-                /*
-                 * Below logic find the start and end point
-                 * to replace the selected auto complete suggestion.
-                 */
-                var token = self.editor.getTokenAt(cur),
-                  start, end, search;
-                if (token.end > cur.ch) {
-                  token.end = cur.ch;
-                  token.string = token.string.slice(0, cur.ch - token.start);
-                }
+              /*
+               * Below logic find the start and end point
+               * to replace the selected auto complete suggestion.
+               */
+              var token = self.editor.getTokenAt(cur),
+                start, end, search;
+              if (token.end > cur.ch) {
+                token.end = cur.ch;
+                token.string = token.string.slice(0, cur.ch - token.start);
+              }
 
-                if (token.string.match(/^[.`\w@]\w*$/)) {
-                  search = token.string;
-                  start = token.start;
-                  end = token.end;
-                } else {
-                  start = end = cur.ch;
-                  search = '';
-                }
+              if (token.string.match(/^[.`\w@]\w*$/)) {
+                search = token.string;
+                start = token.start;
+                end = token.end;
+              } else {
+                start = end = cur.ch;
+                search = '';
+              }
 
-                /*
-                 * Added 1 in the start position if search string
-                 * started with "." or "`" else auto complete of code mirror
-                 * will remove the "." when user select any suggestion.
-                 */
-                if (search.charAt(0) == '.' || search.charAt(0) == '``')
-                  start += 1;
-
-                cb({
-                  list: result,
-                  from: {
-                    line: self.current_line,
-                    ch: start,
-                  },
-                  to: {
-                    line: self.current_line,
-                    ch: end,
-                  },
-                });
-              },
-              error:function(e) {
-                return httpErrorHandler.handleLoginRequiredAndTransactionRequired(
-                  pgAdmin, self, e, null, [], false
-                );
-              },
+              /*
+               * Added 1 in the start position if search string
+               * started with "." or "`" else auto complete of code mirror
+               * will remove the "." when user select any suggestion.
+               */
+              if (search.charAt(0) == '.' || search.charAt(0) == '``')
+                start += 1;
+
+              cb({
+                list: result,
+                from: {
+                  line: self.current_line,
+                  ch: start,
+                },
+                to: {
+                  line: self.current_line,
+                  ch: end,
+                },
+              });
+            })
+            .fail(function(e) {
+              return httpErrorHandler.handleLoginRequiredAndTransactionRequired(
+                pgAdmin, self, e, null, [], false
+              );
             });
           }.bind(ctx),
         };
@@ -1101,30 +1101,30 @@ define('tools.querytool', [
       $.ajax({
         url: url,
         method: 'GET',
-        success: function(res) {
-          self.handler.has_more_rows = res.data.has_more_rows;
-          $('#btn-flash').prop('disabled', false);
-          self.handler.trigger('pgadmin-sqleditor:loading-icon:hide');
-          self.update_grid_data(res.data.result);
-          self.handler.fetching_rows = false;
-          if (typeof cb == 'function') {
-            cb();
-          }
-        },
-        error: function(e) {
-          $('#btn-flash').prop('disabled', false);
-          self.handler.trigger('pgadmin-sqleditor:loading-icon:hide');
-          self.handler.has_more_rows = false;
-          self.handler.fetching_rows = false;
-          if (typeof cb == 'function') {
-            cb();
-          }
+      })
+      .done(function(res) {
+        self.handler.has_more_rows = res.data.has_more_rows;
+        $('#btn-flash').prop('disabled', false);
+        self.handler.trigger('pgadmin-sqleditor:loading-icon:hide');
+        self.update_grid_data(res.data.result);
+        self.handler.fetching_rows = false;
+        if (typeof cb == 'function') {
+          cb();
+        }
+      })
+      .fail(function(e) {
+        $('#btn-flash').prop('disabled', false);
+        self.handler.trigger('pgadmin-sqleditor:loading-icon:hide');
+        self.handler.has_more_rows = false;
+        self.handler.fetching_rows = false;
+        if (typeof cb == 'function') {
+          cb();
+        }
 
-          let msg = httpErrorHandler.handleQueryToolAjaxError(
-            pgAdmin, self, e, null, [], false
-          );
-          self.update_msg_history(false, msg);
-        },
+        let msg = httpErrorHandler.handleQueryToolAjaxError(
+          pgAdmin, self, e, null, [], false
+        );
+        self.update_msg_history(false, msg);
       });
     },
 
@@ -1946,25 +1946,25 @@ define('tools.querytool', [
             $.ajax({
               url: script_type_url,
               type:'GET',
-              success: function(res) {
-                self.gridView.query_tool_obj.refresh();
-                if (res && res !== '') {
-                  self.gridView.query_tool_obj.setValue(res);
-                }
-                self.init_events();
-              },
-              error: function(jqx) {
-                let msg = '';
-                self.init_events();
-
-                msg = httpErrorHandler.handleQueryToolAjaxError(
-                  pgAdmin, self, jqx, null, [], false
-                );
+            })
+            .done(function(res) {
+              self.gridView.query_tool_obj.refresh();
+              if (res && res !== '') {
+                self.gridView.query_tool_obj.setValue(res);
+              }
+              self.init_events();
+            })
+            .fail(function(jqx) {
+              let msg = '';
+              self.init_events();
+
+              msg = httpErrorHandler.handleQueryToolAjaxError(
+                pgAdmin, self, jqx, null, [], false
+              );
 
-                pgBrowser.report_error(
-                  S(gettext('Error fetching SQL for script: %s.')).sprintf(msg).value()
-                );
-              },
+              pgBrowser.report_error(
+                S(gettext('Error fetching SQL for script: %s.')).sprintf(msg).value()
+              );
             });
           } else {
             self.init_events();
@@ -2086,53 +2086,53 @@ define('tools.querytool', [
         $.ajax({
           url: url,
           method: 'GET',
-          success: function(res) {
-            if (res.data.status) {
-              self.can_edit = res.data.can_edit;
-              self.can_filter = res.data.can_filter;
-              self.info_notifier_timeout = res.data.info_notifier_timeout;
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            self.can_edit = res.data.can_edit;
+            self.can_filter = res.data.can_filter;
+            self.info_notifier_timeout = res.data.info_notifier_timeout;
 
-              // Set the sql query to the SQL panel
-              self.gridView.query_tool_obj.setValue(res.data.sql);
-              self.query = res.data.sql;
+            // Set the sql query to the SQL panel
+            self.gridView.query_tool_obj.setValue(res.data.sql);
+            self.query = res.data.sql;
 
 
-              /* If filter is applied then remove class 'btn-default'
-               * and add 'btn-warning' to change the colour of the button.
-               */
-              if (self.can_filter && res.data.filter_applied) {
-                $('#btn-filter').removeClass('btn-default');
-                $('#btn-filter-dropdown').removeClass('btn-default');
-                $('#btn-filter').addClass('btn-primary');
-                $('#btn-filter-dropdown').addClass('btn-primary');
-              } else {
-                $('#btn-filter').removeClass('btn-primary');
-                $('#btn-filter-dropdown').removeClass('btn-primary');
-                $('#btn-filter').addClass('btn-default');
-                $('#btn-filter-dropdown').addClass('btn-default');
-              }
-              $('#btn-save').prop('disabled', true);
-              $('#btn-file-menu-dropdown').prop('disabled', true);
-              $('#btn-copy-row').prop('disabled', true);
-              $('#btn-paste-row').prop('disabled', true);
-
-              // Set the combo box value
-              $('.limit').val(res.data.limit);
-
-              // If status is True then poll the result.
-              self._poll();
+            /* If filter is applied then remove class 'btn-default'
+             * and add 'btn-warning' to change the colour of the button.
+             */
+            if (self.can_filter && res.data.filter_applied) {
+              $('#btn-filter').removeClass('btn-default');
+              $('#btn-filter-dropdown').removeClass('btn-default');
+              $('#btn-filter').addClass('btn-primary');
+              $('#btn-filter-dropdown').addClass('btn-primary');
             } else {
-              self.trigger('pgadmin-sqleditor:loading-icon:hide');
-              self.update_msg_history(false, res.data.result);
+              $('#btn-filter').removeClass('btn-primary');
+              $('#btn-filter-dropdown').removeClass('btn-primary');
+              $('#btn-filter').addClass('btn-default');
+              $('#btn-filter-dropdown').addClass('btn-default');
             }
-          },
-          error: function(e) {
+            $('#btn-save').prop('disabled', true);
+            $('#btn-file-menu-dropdown').prop('disabled', true);
+            $('#btn-copy-row').prop('disabled', true);
+            $('#btn-paste-row').prop('disabled', true);
+
+            // Set the combo box value
+            $('.limit').val(res.data.limit);
+
+            // If status is True then poll the result.
+            self._poll();
+          } else {
             self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_run_query', [], true
-            );
-            self.update_msg_history(false, msg);
-          },
+            self.update_msg_history(false, res.data.result);
+          }
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_run_query', [], true
+          );
+          self.update_msg_history(false, msg);
         });
       },
 
@@ -2621,132 +2621,132 @@ define('tools.querytool', [
             method: 'POST',
             contentType: 'application/json',
             data: JSON.stringify(req_data),
-            success: function(res) {
-              var grid = self.slickgrid,
-                dataView = grid.getData(),
-                data_length = dataView.getLength(),
-                data = [];
+          })
+          .done(function(res) {
+            var grid = self.slickgrid,
+              dataView = grid.getData(),
+              data_length = dataView.getLength(),
+              data = [];
 
-              if (res.data.status) {
-                if(is_added) {
-                  // Update the rows in a grid after addition
-                  dataView.beginUpdate();
-                  _.each(res.data.query_result, function(r) {
-                    if (!_.isNull(r.row_added)) {
-                      // Fetch temp_id returned by server after addition
-                      var row_id = Object.keys(r.row_added)[0];
-                      _.each(req_data.added_index, function(v, k) {
-                        if (v == row_id) {
-                          // Fetch item data through row index
-                          var item = grid.getDataItem(k);
-                          _.extend(item, r.row_added[row_id]);
-                        }
-                      });
-                    }
-                  });
-                  dataView.endUpdate();
-                }
-                // Remove flag is_row_copied from copied rows
-                _.each(data, function(row) {
-                  if (row.is_row_copied) {
-                    delete row.is_row_copied;
+            if (res.data.status) {
+              if(is_added) {
+                // Update the rows in a grid after addition
+                dataView.beginUpdate();
+                _.each(res.data.query_result, function(r) {
+                  if (!_.isNull(r.row_added)) {
+                    // Fetch temp_id returned by server after addition
+                    var row_id = Object.keys(r.row_added)[0];
+                    _.each(req_data.added_index, function(v, k) {
+                      if (v == row_id) {
+                        // Fetch item data through row index
+                        var item = grid.getDataItem(k);
+                        _.extend(item, r.row_added[row_id]);
+                      }
+                    });
                   }
                 });
-
-                // Remove 2d copied_rows array
-                if (grid.copied_rows) {
-                  delete grid.copied_rows;
+                dataView.endUpdate();
+              }
+              // Remove flag is_row_copied from copied rows
+              _.each(data, function(row) {
+                if (row.is_row_copied) {
+                  delete row.is_row_copied;
                 }
+              });
 
-                // Remove deleted rows from client as well
-                if (is_deleted) {
-                  var rows = grid.getSelectedRows();
-                  if (data_length == rows.length) {
-                    // This means all the rows are selected, clear all data
-                    data = [];
-                    dataView.setItems(data, self.client_primary_key);
-                  } else {
-                    dataView.beginUpdate();
-                    for (var i = 0; i < rows.length; i++) {
-                      var item = grid.getDataItem(rows[i]);
-                      data.push(item);
-                      dataView.deleteItem(item[self.client_primary_key]);
-                    }
-                    dataView.endUpdate();
+              // Remove 2d copied_rows array
+              if (grid.copied_rows) {
+                delete grid.copied_rows;
+              }
+
+              // Remove deleted rows from client as well
+              if (is_deleted) {
+                var rows = grid.getSelectedRows();
+                if (data_length == rows.length) {
+                  // This means all the rows are selected, clear all data
+                  data = [];
+                  dataView.setItems(data, self.client_primary_key);
+                } else {
+                  dataView.beginUpdate();
+                  for (var i = 0; i < rows.length; i++) {
+                    var item = grid.getDataItem(rows[i]);
+                    data.push(item);
+                    dataView.deleteItem(item[self.client_primary_key]);
                   }
-                  self.rows_to_delete.apply(self, [data]);
-                  grid.setSelectedRows([]);
+                  dataView.endUpdate();
                 }
-
+                self.rows_to_delete.apply(self, [data]);
                 grid.setSelectedRows([]);
+              }
 
-                // Reset data store
-                self.data_store = {
-                  'added': {},
-                  'updated': {},
-                  'deleted': {},
-                  'added_index': {},
-                  'updated_index': {},
-                };
+              grid.setSelectedRows([]);
 
-                // Reset old primary key data now
-                self.primary_keys_data = {};
+              // Reset data store
+              self.data_store = {
+                'added': {},
+                'updated': {},
+                'deleted': {},
+                'added_index': {},
+                'updated_index': {},
+              };
 
-                // Clear msgs after successful save
-                $('.sql-editor-message').html('');
+              // Reset old primary key data now
+              self.primary_keys_data = {};
 
-                alertify.success(gettext('Data saved successfully.'));
-              } else {
-                // Something went wrong while saving data on the db server
-                $('#btn-flash').prop('disabled', false);
-                $('.sql-editor-message').text(res.data.result);
-                var err_msg = S(gettext('%s.')).sprintf(res.data.result).value();
-                alertify.error(err_msg, 20);
-                grid.setSelectedRows([]);
-                // To highlight the row at fault
-                if (_.has(res.data, '_rowid') &&
-                  (!_.isUndefined(res.data._rowid) || !_.isNull(res.data._rowid))) {
-                  var _row_index = self._find_rowindex(res.data._rowid);
-                  if (_row_index in self.data_store.added_index) {
-                    // Remove new row index from temp_list if save operation
-                    // fails
-                    var index = self.handler.temp_new_rows.indexOf(res.data._rowid);
-                    if (index > -1) {
-                      self.handler.temp_new_rows.splice(index, 1);
-                    }
-                    self.data_store.added[self.data_store.added_index[_row_index]].err = true;
-                  } else if (_row_index in self.data_store.updated_index) {
-                    self.data_store.updated[self.data_store.updated_index[_row_index]].err = true;
+              // Clear msgs after successful save
+              $('.sql-editor-message').html('');
+
+              alertify.success(gettext('Data saved successfully.'));
+            } else {
+              // Something went wrong while saving data on the db server
+              $('#btn-flash').prop('disabled', false);
+              $('.sql-editor-message').text(res.data.result);
+              var err_msg = S(gettext('%s.')).sprintf(res.data.result).value();
+              alertify.error(err_msg, 20);
+              grid.setSelectedRows([]);
+              // To highlight the row at fault
+              if (_.has(res.data, '_rowid') &&
+                (!_.isUndefined(res.data._rowid) || !_.isNull(res.data._rowid))) {
+                var _row_index = self._find_rowindex(res.data._rowid);
+                if (_row_index in self.data_store.added_index) {
+                  // Remove new row index from temp_list if save operation
+                  // fails
+                  var index = self.handler.temp_new_rows.indexOf(res.data._rowid);
+                  if (index > -1) {
+                    self.handler.temp_new_rows.splice(index, 1);
                   }
+                  self.data_store.added[self.data_store.added_index[_row_index]].err = true;
+                } else if (_row_index in self.data_store.updated_index) {
+                  self.data_store.updated[self.data_store.updated_index[_row_index]].err = true;
                 }
-                grid.gotoCell(_row_index, 1);
               }
+              grid.gotoCell(_row_index, 1);
+            }
 
-              // Update the sql results in history tab
-              _.each(res.data.query_result, function(r) {
-                self.gridView.history_collection.add({
-                  'status': r.status,
-                  'start_time': self.query_start_time,
-                  'query': r.sql,
-                  'row_affected': r.rows_affected,
-                  'total_time': self.total_time,
-                  'message': r.result,
-                });
+            // Update the sql results in history tab
+            _.each(res.data.query_result, function(r) {
+              self.gridView.history_collection.add({
+                'status': r.status,
+                'start_time': self.query_start_time,
+                'query': r.sql,
+                'row_affected': r.rows_affected,
+                'total_time': self.total_time,
+                'message': r.result,
               });
-              self.trigger('pgadmin-sqleditor:loading-icon:hide');
+            });
+            self.trigger('pgadmin-sqleditor:loading-icon:hide');
 
-              grid.invalidate();
-              if (self.close_on_save) {
-                self.close();
-              }
-            },
-            error: function(e) {
-              let stateParams = [view, controller, save_as];
-              let msg = httpErrorHandler.handleQueryToolAjaxError(
-                pgAdmin, self, e, '_save', stateParams, true
-              );
-              self.update_msg_history(false, msg);
-            },
+            grid.invalidate();
+            if (self.close_on_save) {
+              self.close();
+            }
+          })
+          .fail(function(e) {
+            let stateParams = [view, controller, save_as];
+            let msg = httpErrorHandler.handleQueryToolAjaxError(
+              pgAdmin, self, e, '_save', stateParams, true
+            );
+            self.update_msg_history(false, msg);
           });
         }
       },
@@ -2872,32 +2872,32 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function(res) {
-            self.gridView.query_tool_obj.setValue(res);
-            self.gridView.current_file = e;
-            self.setTitle(self.gridView.current_file.split('\\').pop().split('/').pop(), true);
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            // hide cursor
-            $busy_icon_div.removeClass('show_progress');
+        })
+        .done(function(res) {
+          self.gridView.query_tool_obj.setValue(res);
+          self.gridView.current_file = e;
+          self.setTitle(self.gridView.current_file.split('\\').pop().split('/').pop(), true);
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          // hide cursor
+          $busy_icon_div.removeClass('show_progress');
 
-            // disable save button on file save
-            $('#btn-save').prop('disabled', true);
-            $('#btn-file-menu-save').css('display', 'none');
+          // disable save button on file save
+          $('#btn-save').prop('disabled', true);
+          $('#btn-file-menu-save').css('display', 'none');
 
-            // Update the flag as new content is just loaded.
-            self.is_query_changed = false;
-            setTimeout(() => { self.gridView.query_tool_obj.focus(); }, 200);
-          },
-          error: function(e) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let stateParams = [_e];
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_select_file_handler', stateParams, false
-            );
-            alertify.error(msg);
-            // hide cursor
-            $busy_icon_div.removeClass('show_progress');
-          },
+          // Update the flag as new content is just loaded.
+          self.is_query_changed = false;
+          setTimeout(() => { self.gridView.query_tool_obj.focus(); }, 200);
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let stateParams = [_e];
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_select_file_handler', stateParams, false
+          );
+          alertify.error(msg);
+          // hide cursor
+          $busy_icon_div.removeClass('show_progress');
         });
       },
 
@@ -2920,32 +2920,32 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function(res) {
-            if (res.data.status) {
-              alertify.success(gettext('File saved successfully.'));
-              self.gridView.current_file = e;
-              self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, ''), true);
-              // disable save button on file save
-              $('#btn-save').prop('disabled', true);
-              $('#btn-file-menu-save').css('display', 'none');
-
-              // Update the flag as query is already saved.
-              self.is_query_changed = false;
-              setTimeout(() => { self.gridView.query_tool_obj.focus(); }, 200);
-            }
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            if (self.close_on_save) {
-              self.close();
-            }
-          },
-          error: function(e) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let stateParams = [_e];
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_save_file_handler', stateParams, false
-            );
-            alertify.error(msg);
-          },
+        })
+        .done(function(res) {
+          if (res.data.status) {
+            alertify.success(gettext('File saved successfully.'));
+            self.gridView.current_file = e;
+            self.setTitle(self.gridView.current_file.replace(/^.*[\\\/]/g, ''), true);
+            // disable save button on file save
+            $('#btn-save').prop('disabled', true);
+            $('#btn-file-menu-save').css('display', 'none');
+
+            // Update the flag as query is already saved.
+            self.is_query_changed = false;
+            setTimeout(() => { self.gridView.query_tool_obj.focus(); }, 200);
+          }
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          if (self.close_on_save) {
+            self.close();
+          }
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let stateParams = [_e];
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_save_file_handler', stateParams, false
+          );
+          alertify.error(msg);
         });
       },
 
@@ -3046,26 +3046,26 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function(res) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            setTimeout(
-              function() {
-                if (res.data.status) {
-                  // Refresh the sql grid
-                  queryToolActions.executeQuery(self);
-                } else {
-                  alertify.alert(gettext('Filter By Selection Error'), res.data.result);
-                }
+        })
+        .done(function(res) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          setTimeout(
+            function() {
+              if (res.data.status) {
+                // Refresh the sql grid
+                queryToolActions.executeQuery(self);
+              } else {
+                alertify.alert(gettext('Filter By Selection Error'), res.data.result);
               }
-            );
-          },
-          error: function(e) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_include_filter', [], true
-            );
-            alertify.alert(gettext('Filter By Selection Error'), msg);
-          },
+            }
+          );
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_include_filter', [], true
+          );
+          alertify.alert(gettext('Filter By Selection Error'), msg);
         });
       },
 
@@ -3105,26 +3105,26 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function(res) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            setTimeout(
-              function() {
-                if (res.data.status) {
-                  // Refresh the sql grid
-                  queryToolActions.executeQuery(self);
-                } else {
-                  alertify.alert(gettext('Filter Exclude Selection Error'), res.data.result);
-                }
-              }, 10
-            );
-          },
-          error: function(e) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_exclude_filter', [], true
-            );
-            alertify.alert(gettext('Filter Exclude Selection Error'), msg);
-          },
+        })
+        .done(function(res) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          setTimeout(
+            function() {
+              if (res.data.status) {
+                // Refresh the sql grid
+                queryToolActions.executeQuery(self);
+              } else {
+                alertify.alert(gettext('Filter Exclude Selection Error'), res.data.result);
+              }
+            }, 10
+          );
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_exclude_filter', [], true
+          );
+          alertify.alert(gettext('Filter Exclude Selection Error'), msg);
         });
       },
 
@@ -3143,26 +3143,26 @@ define('tools.querytool', [
             'trans_id': self.transId,
           }),
           method: 'POST',
-          success: function(res) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            setTimeout(
-              function() {
-                if (res.data.status) {
-                  // Refresh the sql grid
-                  queryToolActions.executeQuery(self);
-                } else {
-                  alertify.alert(gettext('Remove Filter Error'), res.data.result);
-                }
+        })
+        .done(function(res) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          setTimeout(
+            function() {
+              if (res.data.status) {
+                // Refresh the sql grid
+                queryToolActions.executeQuery(self);
+              } else {
+                alertify.alert(gettext('Remove Filter Error'), res.data.result);
               }
-            );
-          },
-          error: function(e) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_remove_filter', [], true
-            );
-            alertify.alert(gettext('Remove Filter Error'), msg);
-          },
+            }
+          );
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_remove_filter', [], true
+          );
+          alertify.alert(gettext('Remove Filter Error'), msg);
         });
       },
 
@@ -3184,28 +3184,28 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(sql),
-          success: function(res) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            setTimeout(
-              function() {
-                if (res.data.status) {
-                  $('#filter').addClass('hidden');
-                  $('#editor-panel').removeClass('sql-editor-busy-fetching');
-                  // Refresh the sql grid
-                  queryToolActions.executeQuery(self);
-                } else {
-                  alertify.alert(gettext('Apply Filter Error'), res.data.result);
-                }
-              }, 10
-            );
-          },
-          error: function(e) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_apply_filter', [], true
-            );
-            alertify.alert(gettext('Apply Filter Error'), msg);
-          },
+        })
+        .done(function(res) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          setTimeout(
+            function() {
+              if (res.data.status) {
+                $('#filter').addClass('hidden');
+                $('#editor-panel').removeClass('sql-editor-busy-fetching');
+                // Refresh the sql grid
+                queryToolActions.executeQuery(self);
+              } else {
+                alertify.alert(gettext('Apply Filter Error'), res.data.result);
+              }
+            }, 10
+          );
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_apply_filter', [], true
+          );
+          alertify.alert(gettext('Apply Filter Error'), msg);
         });
       },
 
@@ -3310,25 +3310,25 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(limit),
-          success: function(res) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            setTimeout(
-              function() {
-                if (res.data.status) {
-                  // Refresh the sql grid
-                  queryToolActions.executeQuery(self);
-                } else
-                  alertify.alert(gettext('Change limit Error'), res.data.result);
-              }, 10
-            );
-          },
-          error: function(e) {
-            self.trigger('pgadmin-sqleditor:loading-icon:hide');
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_set_limit', [], true
-            );
-            alertify.alert(gettext('Change limit Error'), msg);
-          },
+        })
+        .done(function(res) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          setTimeout(
+            function() {
+              if (res.data.status) {
+                // Refresh the sql grid
+                queryToolActions.executeQuery(self);
+              } else
+                alertify.alert(gettext('Change limit Error'), res.data.result);
+            }, 10
+          );
+        })
+        .fail(function(e) {
+          self.trigger('pgadmin-sqleditor:loading-icon:hide');
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_set_limit', [], true
+          );
+          alertify.alert(gettext('Change limit Error'), msg);
         });
       },
 
@@ -3440,22 +3440,22 @@ define('tools.querytool', [
           }),
           method: 'POST',
           contentType: 'application/json',
-          success: function(res) {
-            if (!res.data.status) {
-              alertify.alert(gettext('Cancel Query Error'), res.data.result);
-            }
-            self.disable_tool_buttons(false);
-            is_query_running = false;
-            setTimeout(() => { self.gridView.query_tool_obj.focus(); }, 200);
-          },
-          error: function(e) {
-            self.disable_tool_buttons(false);
+        })
+        .done(function(res) {
+          if (!res.data.status) {
+            alertify.alert(gettext('Cancel Query Error'), res.data.result);
+          }
+          self.disable_tool_buttons(false);
+          is_query_running = false;
+          setTimeout(() => { self.gridView.query_tool_obj.focus(); }, 200);
+        })
+        .fail(function(e) {
+          self.disable_tool_buttons(false);
 
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_cancel_query', [], false
-            );
-            alertify.alert(gettext('Cancel Query Error'), msg);
-          },
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_cancel_query', [], false
+          );
+          alertify.alert(gettext('Cancel Query Error'), msg);
         });
       },
 
@@ -3502,19 +3502,19 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(auto_rollback),
-          success: function(res) {
-            if (!res.data.status)
-              alertify.alert(gettext('Auto Rollback Error'), res.data.result);
-            else
-              self.call_cache_preferences();
-          },
-          error: function(e) {
+        })
+        .done(function(res) {
+          if (!res.data.status)
+            alertify.alert(gettext('Auto Rollback Error'), res.data.result);
+          else
+            self.call_cache_preferences();
+        })
+        .fail(function(e) {
 
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_auto_rollback', [], true
-            );
-            alertify.alert(gettext('Auto Rollback Error'), msg);
-          },
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_auto_rollback', [], true
+          );
+          alertify.alert(gettext('Auto Rollback Error'), msg);
         });
       },
 
@@ -3537,18 +3537,18 @@ define('tools.querytool', [
           method: 'POST',
           contentType: 'application/json',
           data: JSON.stringify(auto_commit),
-          success: function(res) {
-            if (!res.data.status)
-              alertify.alert(gettext('Auto Commit Error'), res.data.result);
-            else
-              self.call_cache_preferences();
-          },
-          error: function(e) {
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, '_auto_commit', [], true
-            );
-            alertify.alert(gettext('Auto Commit Error'), msg);
-          },
+        })
+        .done(function(res) {
+          if (!res.data.status)
+            alertify.alert(gettext('Auto Commit Error'), res.data.result);
+          else
+            self.call_cache_preferences();
+        })
+        .fail(function(e) {
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, '_auto_commit', [], true
+          );
+          alertify.alert(gettext('Auto Commit Error'), msg);
         });
 
       },
@@ -3562,22 +3562,22 @@ define('tools.querytool', [
           method: 'PUT',
           contentType: 'application/json',
           data: JSON.stringify(data),
-          success: function(res) {
-            if (res.success == undefined || !res.success) {
-              alertify.alert(gettext('Explain options error'),
-                gettext('Error occurred while setting %(subItem)s option in explain.',
-                        {subItem : subItem})
-              );
-            }
-            else
-              self.call_cache_preferences();
-          },
-          error: function(e) {
-            let msg = httpErrorHandler.handleQueryToolAjaxError(
-              pgAdmin, self, e, caller, [], true
+        })
+        .done(function(res) {
+          if (res.success == undefined || !res.success) {
+            alertify.alert(gettext('Explain options error'),
+              gettext('Error occurred while setting %(subItem)s option in explain.',
+                      {subItem : subItem})
             );
-            alertify.alert(gettext('Explain options error'), msg);
-          },
+          }
+          else
+            self.call_cache_preferences();
+        })
+        .fail(function(e) {
+          let msg = httpErrorHandler.handleQueryToolAjaxError(
+            pgAdmin, self, e, caller, [], true
+          );
+          alertify.alert(gettext('Explain options error'), msg);
         });
       },
 
diff --git a/web/pgadmin/tools/user_management/static/js/user_management.js b/web/pgadmin/tools/user_management/static/js/user_management.js
index ec3d5153..0b5fe3aa 100644
--- a/web/pgadmin/tools/user_management/static/js/user_management.js
+++ b/web/pgadmin/tools/user_management/static/js/user_management.js
@@ -776,17 +776,17 @@ define([
                 url: ROLEURL,
                 method: 'GET',
                 async: false,
-                success: function(res) {
-                  Roles = res;
-                },
-                error: function() {
-                  setTimeout(function() {
-                    alertify.alert(
-                      gettext('Error'),
-                      gettext('Cannot load user roles.')
-                    );
-                  }, 100);
-                },
+              })
+              .done(function(res) {
+                Roles = res;
+              })
+              .fail(function() {
+                setTimeout(function() {
+                  alertify.alert(
+                    gettext('Error'),
+                    gettext('Cannot load user roles.')
+                  );
+                }, 100);
               });
 
               var view = this.view = new Backgrid.Grid({
