views:

79

answers:

2

I'm working with Colorbox and if I specify to use an iframe with it then the $_SERVER['HTTP_X_REQUESTED_WITH'] variable is no longer available to me. I need that in order to detect if ajax has loaded so then I can include a header/footer or not.

Anyway to get this variable or is there another variable that I can get when I use iframe?

Thanks.

A: 

The variable name might be different you could try print_r($_SERVER); to see the header is different. Although a better approach would be to set a $_GET variable like ?ajax=true

Rook
ya I did a var_dump($_SERVER) and couldn't find anything.
keith
@keith That server variable is only set by an XHR request, if you are loading an iframe then its not going to be set.
Rook
A: 

Setting/changing the <iframe>'s src attribute using JavaScript is definitely not using XMLHttpRequest to load the target page as you seem to think.

Rather pass an extra request parameter or pathinfo. E.g.

iframe.src = 'newpage.php?loadedByJS=true';

Which you in turn can check by $_GET['loadedByJS'].

BalusC
Have you ever used colorbox? Below is the link that pops open the colorbox..you can see the colorbox_youtube class in the javascript code I posted earlier. I cannot just append a url variable to the below because there is no guarantee ajax has loaded 100%. I get what you are saying but I don't see how to do it Colorbox.<a class="colorbox_youtube" href='file.php?id=<?php echo $_GET['id'];?>'>Copy to production</a>
keith