Scott Andrew - lo-fi acoustic pop superhero!

Join the Demo Club to unlock new music, get discounts, tour dates and other neato stuff:

or learn more here.

April 16, 2002

Using XMLHTTPRequest in Mozilla

Mozilla’s XMLHttpRequest object is in many ways identical to Microsoft’s XMLHTTP ActiveX object. Both can be used to make GET and POST requests from the browser. Here’s a handy tip: in Mozilla, don’t forget to use the little-known overrideMimeType() method if the server is returning anything other than text/xml. Otherwise, Mozilla might lock up on you.


try {
  // for Mozilla
  req = new XMLHttpRequest();
  req.overrideMimeType(”text/xml”);
} catch (e) {
  // for IE5+
  req = new ActiveXObject(”Msxml2.XMLHTTP”);
}
req.open(”GET”, “page.html”,false);
req.send(null);

With overrideMimeType() Mozilla can fetch standard HTML pages, or just about anything the server would normally not return as text/xml. IE5+ doesn’t seem to have a problem with non-XML formats; probably due to its not-a-bug-it’s-a-feature behavior of ignoring mimetypes. The standard security restrictions still apply; you cannot do GET or POST requests to locations outside the current domain.

No Comments

Leave a Comment

Close
  • E-mail
  • Social Web

Email this page to a friend:

E-mail It

Buy Music

Download Scott Andrew tracks from iTunes Find Scott Andrew at Rhapsody Find Scott Andrew at Amazon Find Scott 
Andrew at CD Baby Find Scott Andrew at Napster Find Scott Andrew at Emusic

More Options

New Videos

More Videos

Photos

More Photos at Flickr

Recent Reader Comments

  • jim: I too can Moonwalk. Let's get some cardboard on th...
  • megan: Snort! Hee hee hee.
  • scottandrew: Nope, nothing yet on the calendar. :(
  • jim: Very cool. Any other explone Seattle gigs on the h...
  • John: You may have material for half a dozen songs there...