I notice that all my AHAH forms (in the admin) don't work all of a sudden after I updated Drupal and jquery_update. Now that I am working with building a form with the Form API and want to make it dynamic with AHAH through ahah_helper, it hangs itself.

For example, if I type something into a textfield that is supposed to change on blur, the throbber pops up and I can see that the form is trying to POST the change, but then this error comes up:

uncaught exception: Syntax error, unrecognized expression: /\x3e\n\x3c/div\x3e\n\x3c/div\x3e"

and it says it's from the jquery.min.js file. I am using 1.5.

I have heard that this can be because of conflicting files in other modules, and I have tried several different patches for those modules; none of them work.

Does anyone have an insight on this? Or should I use AJAX instead?

1 Answer 1


Better late than never...

Well the problem is in the Drupal server response, which is not valid json. You need to patch drupal_js function in commons.inc.

diff --git a/includes/common.inc b/includes/common.inc
index 80fc911..084b5fc 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2551,8 +2551,8 @@ function drupal_to_js($var) {
     case 'resource':
     case 'string':
       return '"'. str_replace(array("\r", "\n", "<", ">", "&"),
-                              array('\r', '\n', '\x3c', '\x3e', '\x26'),
-                              addslashes($var)) .'"';
+                              array('\r', '\n', '\u003c', '\u003e', '\u0026'),
+                              str_replace("\'","'", addslashes($var))) .'"';
     case 'array':
       // Arrays in JSON can't be associative. If the array is empty or if it
       // has sequential whole number keys starting with 0, it's not associative
  • Does this fix break old versions of jQuery (i.e. 1.2 or whichever ships with Drupal 6) ?
    – Nic
    Oct 30, 2014 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.