Download & Extend

jQuery 1.4.x compatibility

Project:Hierarchical Select
Version:6.x-3.7
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (cannot reproduce)
Issue tags:jQuery 1.4.x

Issue Summary

When using jquery 1.4.2 and Hierarchical Select 6.x-3.1 I get this message 'Received an invalid response from the server.'.

This is when I choose an element in a select dropdown and the dependant dropdown is about to load.

Comments

#1

Are you sure this is not a duplicate? Do you mean that this only happens with jquery 1.4.2 and not with other versions?

I am asking because there are already a bunch of issues referring to similar issues. Just a search with the terms 'invalid response server' reveals a couple of dozens of them:

http://drupal.org/project/issues/hierarchical_select?text=invalid+respon...

...some are duplicates, others are closed. So, are you sure this has not been reported before?

#2

Same here with jQuery 1.4.2.

In fact this error is specific to all jQuery 1.4.x line. I had no problems with 1.3.2 and older.

Thus confirming.

#3

Title:Incompability with jquery 1.4.2» jQuery 1.4.x compatibility
Version:6.x-3.1» 6.x-3.5
Status:active» postponed (maintainer needs more info)

So few reports, so I'm hesitant to think this is a real issue? Can somebody confirm this is still a problem? i.e. jQuery 1.4.x + HS

#4

Status:postponed (maintainer needs more info)» closed (cannot reproduce)

Closing due to lack of response. Feel free to reopen.

#5

Version:6.x-3.5» 6.x-3.6
Status:closed (cannot reproduce)» active

It seems that the trigger events may not be getting fired properly when using jQuery 1.4.2.

If I add alert('test'); after line 579 of hierarchical_select.js then I get an alert after the animation of a changed HS element as expected.

However if I add JS to trigger to the page $('.hierarchical-select-wrapper').bind('change-hierarchical-select', function() { alert('test') }); based on the code from API.txt then no alert is triggered.

#6

I am observing a similar problem like realityloop in #5. Strangely this does not happen every time. My problem was caused by empty responses from the json callback and not by the jQuery stuff.

#7

I think that this issue is due to an incompatibility between jQuery 1.4 and drupal_to_js function (http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_to...). Indeed, jQuery 1.4 seems to use a new method to parse JSON.

drupal_to_js function is used in hierarchical_select.module file (l.362).

In Drupal 7, a new function has been implemented to replace drupal_to_js : drupal_json_encode (http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_js...).

So, in drupal 6 common.inc file (l.2499), replacing

return '"'. str_replace(array("\r", "\n", "<", ">", "&"),
                              array('\r', '\n', '\x3c', '\x3e', '\x26'),
                              addslashes($var)) .'"';

by
return str_replace(array("<", ">", "&"), array('\u003c', '\u003e', '\u0026'), json_encode($var));

seems to solve this issue.

#8

@glefebvre: Are you referring to #479368: D7: Create RFC compliant HTML safe JSON in drupal core?

#9

...never mind. It's #222578: alter drupal_to_js() to use json_encode(), but it is for d7 only and was never suggested to be backported to d6, so I dropped a question there.

#10

...though the patch in that issue removes a whole lot more lines of code and the change is:

return str_replace(array("<", ">", "&"), array('\x3c', '\x3e', '\x26'), json_encode($var));

instead of your proposed:

return str_replace(array("<", ">", "&"), array('\u003c', '\u003e', '\u0026'), json_encode($var));

#11

Category:bug report» task
Status:active» needs work

Please roll a proper patch. I would also like to see reviews from others. Before that happens, I obviously cannot commit this.

I will close this in 2 weeks if the above hasn't happened by then, since this obviously affects very few people. So it may also be a conflict — can this be reproduced on a vanilla Drupal installation?

#12

Status:needs work» closed (works as designed)

Closing due to lack of response.

#13

Version:6.x-3.6» 6.x-3.x-dev
Status:closed (works as designed)» postponed (maintainer needs more info)

Wim, I am changing this to postponed and I kindly ask you to not close it till I run a few tests (against latest 6.x dev) first and confirm reproduction of the issue or not. Thanx.

PS: btw, jQuery 1.5 is out. I'll check to see how HS works on that too.

#14

Version:6.x-3.x-dev» 6.x-3.7

Okay, great! :)

This now goes against the 3.7 release I just made :)

#15

Status:postponed (maintainer needs more info)» closed (cannot reproduce)

I see no problems so far, but my tests are not on a production environment (with actual data and real traffic I mean). So, I guess we can close it, since if the error comes up again one can re-open this issue.

I didn't have the time to check with latest jQuery 1.5 as promised though. Might do so during the weekend, but I cannot promise anything. Anyways, I guess both developers and ISPs will eventually upgrade to 1.5 and if there are any issues we'll have feedback on them.

PS (for future reference): speed-reading through the issue I see that the issue seems to be occurring only in jQuery 1.4.x setups, so I am tagging it as such.

nobody click here