Index: misc/ajax.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/ajax.js,v
retrieving revision 1.18
diff -u -p -r1.18 ajax.js
--- misc/ajax.js	25 Jun 2010 20:34:07 -0000	1.18
+++ misc/ajax.js	26 Aug 2010 21:54:44 -0000
@@ -107,7 +107,14 @@ Drupal.ajax = function (base, element, e
 
   // Replacing 'nojs' with 'ajax' in the URL allows for an easy method to let
   // the server detect when it needs to degrade gracefully.
-  this.url = element_settings.url.replace(/\/nojs(\/|$)/g, '/ajax$1');
+  // There are four scenarios to check for:
+  // 1. /nojs/
+  // 2. /nojs$ - The end of a URL string.
+  // 3. /nojs? - Followed by a query (with cleanurls enabled).
+  //      eg: path/nojs?destination=foobar
+  // 4. /nojs& - Followed by a query (without cleanurls enabled).
+  //      eg: ?q=path/nojs&destination=foobar
+  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
