views:

56

answers:

4

I know you can get a $_SERVER['HTTP_X_REQUESTED_WITH'] php variable if jquery has loaded. That's great but if you use an iframe then that variable is no longer available. Is there a way to detect if jquery has loaded and give php a varaible in an iframe? I don't want to load a header or footer if jquery has loaded 100% but otherwise put them on. I have to use an iframe so there is no way around that. (I'm using a Colorbox iframe).

Thank you.

+3  A: 

This approach seems error-prone. Do you have a good reason for waiting until jQuery has loaded before loading the header and footer? Are these actions that could be performed client-side via jQuery's AJAX functions?

Justin Ethier
I am using Colorbox iframe. I don't want the header or footer to show if two things:1) Javascript is enabled2) jquery has loadedI say number 2 because a page can be heavy and still loading and if someone clicks on a link that is a colorbox then the new page will not be in a colorbox. It will just go to a new page. I do not want it to go to a new page without the header or footer. However, if Colorbox loaded correctly then I don't want a header or footer.
Keith
I agree, if I understand the OP's goals correctly, this seems like something that could be solved with an AJAX request ala $(window).load(function() { $.ajax(...); })
hemp
A: 

PHP => Browser => Javascript

You can't communicate from javascript to php such that php would genereate different data based on javascript.

You can do a documentReady() to hide a div when jquery is loaded.

Byron Whitlock
+1  A: 

I know you can get a $_SERVER['HTTP_X_REQUESTED_WITH'] php variable if jquery has loaded.

That's not what that variable indicates.

That variable indicates that a particular request was made with jQuery's AJAX functions.

ceejayoz
+1 yup, it has nothing whatsoever to do with whether jQuery is active on the parent page or anywhere else.
Pekka
A: 

You probably want to hide the content with CSS using "display:none;" when Colorbox is enabled, You'd be still loading the footer and header but they won't show up

sinisterff
Excellent idea. Never thought of that. Thank you.
Keith
This solution may drastically affect the page. If the intent is to load the other page into the main page via AJAX, hiding header/footer won't prevent its scripts, CSS, etc. from being loaded into the loading page. Might wreak havoc in some situations.
ceejayoz