Welcome Guest, Not a member yet? Register   Sign In
Controller gets called twice because of included javascript?!?
#1

[eluser]sl3dg3hamm3r[/eluser]
Hey there

I took me quite a bit of pain 'till I figured out what is the cause of my controller being called twice in a row. It is because of these two lines in my view, which include the javascript framework jquery and thickbox for picture-viewing:

Code:
< X src="&lt;?php echo base_url();?&gt;js/jquery.js"> Y
< X src="&lt;?php echo base_url();?&gt;js/thickbox.js">Y

X: script type="text/javascript"
Y: /script
(otherwise it would be filtered by the forum)

If I leave one (or both) includes away, the controller won't get called twice anymore. Does anybody have a clue why the heck my controller gets called again because of the above two lines? Sad

Oliver
#2

[eluser]Dam1an[/eluser]
The only thing I can think of, would be that the initialisation of one of those files is causing a HTTP request for the current page, which might cause the controller to execute again (although that would cause a chain reaction, wouldn't it?)

That being said, people have used jQuery with CI before with no (known) problems :-S
#3

[eluser]Colin Williams[/eluser]
There is probably some reference in either of those libraries to your file system that is incorrectly being served by CodeIgniter. I would venture to guess it is a loading graphic for thickbox that is getting a 404 and CI is set to handle 404s.
#4

[eluser]sl3dg3hamm3r[/eluser]
wohaaa, thank you guys! Absolutely right, in thickbox.js, there you would find following line at the top:

Code:
var tb_pathToImate = "img/loadingAnimation.gif"

First of all I forgot to copy this image to the img-folder, second (which suprised me a little) it doesn't work with the relative path.

Gosh, I was debugging a whole afternon CI's Session-class, since one side-effect of the double-callings (I was not aware first) was messed up session-vars... And now, the site seems to be suddenly fast Wink

Well, enjoy Sunday, and thanks again!
Oliver
#5

[eluser]Colin Williams[/eluser]
It pays (literally) to know these technologies inside and out.
#6

[eluser]sl3dg3hamm3r[/eluser]
jup, that's the bright side of hunting down such issues Smile
#7

[eluser]quest13[/eluser]
Can you suggest me which library / helper I should include in my controller to enable thickbox function ?
#8

[eluser]Thorpe Obazee[/eluser]
[quote author="quest13" date="1245856548"]Can you suggest me which library / helper I should include in my controller to enable thickbox function ?[/quote]

You don't need any. You can work with thickbox just like any html/php page
#9

[eluser]tommebasso[/eluser]
I seem to have the same problem, but I don't find a cure.

I’m logging each page view in a db-table, writing the controller, the function, page-title, session-id, timestamp, browser and ip into a record.
My application seems to work fine, but when I look at the records with the logging data I see that certain pages get loaded three or more times; or at least they get logged more times, because it doesn’t seem that the browser really reloads the pages.
In the log-records, the session-id and the timestamp differs (it’s always about 1 to 3 seconds from one record to the next). Of course I verified that the page only got viewed once.
And now the fun thing: this happens quite often, but not every time.
I have google-maps and google-analytics in my page-view; can it be, that those javascripts trigger those extra calls somehow?

And is it possible, that those xtra calls change the session data? only in IE?
My site works perfect in firefox+safari+opera, but in IE some functions, which require session-data fail, because the required session variable has been set to "favicon.ico" or "/lay" (whereas in ff et.al. the session var remains correct).

If missing links are the cause to the problem, is ist poosible to prevent CI from handling these errors?

#edit#
I checked what is called from the site with FF-Addon "HTTP Live headers" and went over all listed items - every item (images, css- and js-files) seems to be in place so there shouldnt be no missing file




Theme © iAndrew 2016 - Forum software by © MyBB