views:

642

answers:

3

I have a page that gathers environment status from a couple of IBM WebSphere servers using iframes similar to this:

<iframe src="http://server:9060/ibm/console/status?text=true&amp;amp;type=server&amp;amp;node=NODE&amp;amp;name=ServerName_server_NODE"&gt;&lt;/iframe&gt;

and it happily prints out "Started" or "Unavailable" etc. But if I load the same url in a normal browser sometimes it works, sometimes it does not? Some of them are showing a login page, while others are simply return HTTP code 500.

So whats the difference between loading the page through an iframe vs through a browser?

I can tell you that the iframe solution works no matter which machine I am doing it on, so I do not belive it has anything to do with the user whos opening the page. And before you ask, why not keep the solution that works, well its because it takes a long time to open the page with the iframes vs a page where everything is requested through ajax.

Update: Using jQuery to perform the ajax call returns "error" and "undefined" for the servers that I can't see in a normal browser.

A: 

An iframe is essentially the same as opening with the browser. In both cases the browsers credentials are used, so there will be no difference between the two.

Secondly, loading something in an iframe should take the same amount of time as requesting it through XHR, since in both cases the browser makes an HTTP request and waits for the response. Although I should add that an iframe will take time to render the content onto the page. However if you plan on displaying it with ajax anyways, an iframe/xhr solution will be more or less the same.

Ian Elliott
There is a huge difference in the loading time between the two pages. The ajax page loads almost instantly and the statuses are populated once they receive a response, while the iframe version is not loaded before all the iframes have their response.
Tinus
A: 

One difference is an iframe has to render the view while XHR would not.

Chris
Indeed, but the request itself is unchanged.
Ian Elliott
A: 

In case of ajax request same origin policy (which restricts cross domain call) comes into picture. So you can't make cross domain call using xhr. Alternative for same is embed flex swf file in your page as activex control and make flex call through javascript and then flex is responsible to make cross domain call (flex can if targeted domain allows cross domain using crossdomain.xml) and renders result using javascript again.

Silent Warrior
I thought of that as well, but how come it works for some of the servers and not all? They should all be on the same domain.
Tinus