Ok, this is not a code snippet article. It’s just an experience which you probably already met, but it was nightmare to find and it took me 1/2 a day to fix this “stupid” bug.
So what is the case?
Working on a project including some advanced JavaScript and Ajax techniques my coworker Milen noticed that the Session is not behaving as expected. In a simple function like:
if ($id != false) {
echo $id;
echo $k = $this->Session->read('some_var');
$this->Session->write('some_var', $id);
}
$this->set('tests', $this->paginate());
}
The result should be quite easy to be predicted: if you pass for example 5 on the second reload the $k should be with the same value as $id. Unfortunately instead of 5 the $k was ‘images’. Yep, quite strange, isn’t it?
if you put die() at the end of the function, the result is as expected.
What was the problem
In our current project we are using jQuery and some of it’s plugins. So the problems was in the ThickBox plugin. If you remove it from the header everything works.
Digging into unpacked version of the plugin we’ve noticed that the loading picture is not where it should be. there is an variable
and as you may notice the path is not compatible with Cake convention and obviously it’s not in the http://server/cakeapp/tests/test/images/.
In the example above we were writing id into the session. Yes but calling: http://server/cakeapp/tests/test/images/loadingAnimation.gif mean that $id take value of ‘images’.
It was quite tricky, because if you loading CSS or JavaScript and the file is not there, FireBug or even the html /if there is no correct CSS the styling will fail/ will warn the developer, but image loaded into the JS function is quite difficult to find.
Anyway, the conclusion is “Watch you JavaScript libs and what files they require”.
Always good to use some kind of a debugging proxy – charles, livehttpheaders, etc. What turned out to be half-day hunt could be fixed within 10 minutes.
Well, it’s easy when you know what to looking. If you have problems with session you are not looking for missing images, right 🙂
I am using Firebug, but you need to check the image which are loading, which you usually never check.
Hi, I have been visiting your site a few times recently and I like the way you write about things, you have a very interesting perspective. Good things.
Thanks for your information .. very useful blog ..
where i put image for thick box ?
Well, it’s better to modify the tickbox source and to change the path to the image. Otherwise it will be very difficult to handle everything.