Gallerix module AJAX problem with IE.
superfedya - October 28, 2009 - 15:43
| Project: | Gallerix |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
I have a problem with Gallerix module (AJAX fonction), so I tried to add gallery nodes to exception list, like this:
-Statically cache specific pages:
-Cache every page except the listed pages.
node/75 - my gallery node.
But this node always cached and annonym users cannot use AJAX gallery fonction with IE browser:
Webpage error details
Message: Invalid character
Line: 434
Char: 3
Code: 0
URI: http://www.madfanboy.com/site/sites/default/files/js/js_aba32314c4039c03...
Line 434: var json = eval('('+ content +')');
Thanks!

#1
Problem here is with the Gallerix Module. Module looks like it's abandoned; author used drupal_to_js() instead of drupal_json() when outputting JSON to the browser. Looks like he even made his own hack to get it to work.
<?php/**
* All calls to print JSON for a Gallerix module should go through this wrapper function.
*
*/
function gallerix_to_js($data) {
//This delimiter is crucial, otherwise modules like devel will break JSON parsing.
return '##BEGIN_JSON##' . drupal_to_js($data) . '##END_JSON##';
}
?>
Anyway all calls to
print gallerix_to_jsshould be replaced withdrupal_jsonand the Boost & this module should work then.As for the setting, when I go to node/75 I get a 404 which means that node doesn't exist. Make sure you have the right node id.
#2
http://www.madfanboy.com/site/node/75 100% working.
So, if I am not a programmer, no way I can fix Gallerix?
#3
Put
site/node/75in the box then instead ofnode/75#4
I tried site/node/75, not effect.
But node/75 it is a working path, I use the same for blocks exception.
#5
I just tried the
Statically cache specific pages:[x] Cache every page except the listed pages.
Setting and it works... I need more info on your particular setup and the issue your encountering because code does work out of the box.
#6
I just disable all my modules, except Boosts and Gallerix - same results. I tried on my shared hostig, as on localhost - always same result.
But, if I use Firefox or Chrome browser, Gallerix works perfectly with a Boost, problems only with a Internet Explorer...
#7
http://drupal.org/patch/apply
Patch is extra large due to my text editor auto correcting white space issues in the module. All this does is replace
print gallerix_to_jswithdrupal_json. You need to apply this patch to the gallerix module; Boost tends to bring out the flaws in code, including my own code.See if the
Cache every page except the listed pages.setting works with gallerix disabled.#8
Thanks!
I apply this patch on my localhost and now pictures dont load with any browser and even for auth users...
Line:108
Char:3
Code:0
Error:Syntax error
URL:http://localhost/site/modules/gallerix/js/common.js?b
Line 108 of common.js:
"var json = eval('('+ content +')');"
For exception list, I found a solution! I add this line to exception list: "gallerix/*" and its works!
#9
ah that makes since, it's doing a ajax call back under the path gallerix.
Sounds like the module creator baked in the ### code fairly heavily... Re-download a fresh copy to undo the patch I gave you. Try this one
#10
Line:108
Char:3
Code:0
Error:Invalid character
URL:http://localhost/site/modules/gallerix/js/common.js?4
But ok, no problem, I add gallerix to my exception list.
#11
All I can say is wow... Here's the javascript code
/**
* A wrapper for parsing JSON. Unlike the original function, this
* wrapper does not break when Devel is printing SQL queries.
*
*
*/
Gallerix.parseJson = function (data) {
// Only parse content in between the delimiters.
var begin = data.indexOf('##BEGIN_JSON##');
var end = data.lastIndexOf('##END_JSON##');
var content = data.substring(begin + 14, end);
var json = eval('('+ content +')');
json.remainder = data.substring(end + 12);
return json;
}
This code is the source of the issue
var content = data.substring(begin + 14, end);The 14 number needs to be adjusted; or the end offset needs to be adjusted to the end atjson.remainder = data.substring(end + 12);I'm moving this over to the gallerix issue tracker.
http://drupal.org/project/issues/gallerix
Disable ajax caching in boost