The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

XMLHttpRequest vs Hidden IFrame Scripting

When building AJAX applications, what criteria would you use to decide between using an XMLHttpRequest object or a hidden IFrame with remote scripting?
John Topley Send private email
Tuesday, May 03, 2005
 
 
I would use XMLHTTP where possible because it's designed for the purpose of getting arbitrary data, whereas Iframe solutions are a hack to do the same thing.  The reason Iframe (and img/cookie and script injection) solutions were developed is that XMLHTTP was late on the cross-platform scene, so we had to make things work by any other means.

So, use XMLHTTP unless your target browser audience doesn't support it.

Mind you, I've always had good experience with Iframe-based RPC, but this being The Design of Software, XMLHTTP is the preferred architecture in my opinion.
Brent Ashley Send private email
Tuesday, May 03, 2005
 
 
One of the arguments that is starting to appear against XMLHTTPRequest is the fact that it is a nightmare to debug.  Not having used it directly, I can't speak to that.

One of the arguments about hidden IFrames is that it is *very* non-linear in programming.  Therefore, it can be hard to trace and track things for debugging.  I have been doing this for quite a while and there is some truth there.

I get around that by having certain iframes show larger that 0x0 when they detect my login.  This allows me to see the detailed debugging information.
KC Send private email
Tuesday, May 03, 2005
 
 
I'd recommend XMLHttpRequest going forward. If your audience doesn't support it then of course you have no choice. I've done some ajax experiments with XMLHttpRequest and it is slick. It's pretty widely available now and will only show up in more places going forward.

As for debugging, you can still make a debug window or div for your output. Then there's also the Venkmann debugger. The complexity does mean that you need to think out your design, but since when is that a bad thing? ;)
Rob Send private email
Tuesday, May 03, 2005
 
 
Thanks for the advice, guys.
John Topley Send private email
Tuesday, May 03, 2005
 
 
So what did you decide John Topley?
Pythonic Send private email
Tuesday, May 03, 2005
 
 
Please , call me John. I'm going to go with XMLHttpRequest. What I'm really interested in working at a slightly higher level of abstraction, so I'm going to investigate DWR - http://www.getahead.ltd.uk/dwr/ and probably some other frameworks.
John Topley Send private email
Tuesday, May 03, 2005
 
 
Ruby on Rails has a Javascript framework to simplify AJAX apps. I think it is meant to be useful for any server side application not just Ruby.

One of the important things to consider is use of 'back' button while doing your Ajax application. I think using IFrame allows that. I had read an article about it but can't seem to find it right now. Did you check delicious tag for AJAX, I am sure you would find tons of useful information. [Btw, check delicious tag is my primary method of discovering something interesting/useful. :)]

JD
JD Send private email
Wednesday, May 04, 2005
 
 
DWR lets you select iframe or xmlhttpreq very simply on a call by call basis. By default it picks for you (because xmlhttpreq is not available everywhere) but if back button is important you can select iframe only.

See http://www.getahead.ltd.uk/dwr/

DWR makes it simple to call Java on the server directly from Javascript in the browser marshalling all the parameters and return values.
Joe Walker
Thursday, May 05, 2005
 
 
"One of the arguments that is starting to appear against XMLHTTPRequest is the fact that it is a nightmare to debug.  Not having used it directly, I can't speak to that.
"

huh?

I have no problems debugging.  I use Visual Studio.NET and have wrote many AJAX applications using .NET, ASP, and PHP.

My javascript is always located in .js files and I can step into my code quite easily with VS.NET.  Simply put a breakpoint in the .js file.

IFrame is not Section 508 compliant if that means anything
NET
Thursday, May 05, 2005
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz