diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index 71399c4..aaea3d8 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -122,7 +122,9 @@ Drupal.ajax = function (base, element, element_settings) {
   // 2. /nojs$ - The end of a URL string.
   // 3. /nojs? - Followed by a query (e.g. path/nojs?destination=foobar).
   // 4. /nojs# - Followed by a fragment (e.g.: path/nojs#myfragment).
-  this.url = element_settings.url.replace(/\/nojs(\/|$|\?|#)/g, '/ajax$1');
+  if ($.isFunction(element_settings.url.replace)) {
+    this.url = element_settings.url.replace(/\/nojs(\/|$|\?|#)/g, '/ajax$1');
+  }
   this.wrapper = '#' + element_settings.wrapper;
 
   // If there isn't a form, jQuery.ajax() will be used instead, allowing us to
