jQuery XML and MIME types

February 16, 2009 08:49 by tim

We're really getting into jQuery these days.  Since it's adoption by the .net framework team, we're seeing more and more AJAX UI with data read in via jQuery to make some really cool looking sites

However, there was a problem we had recently with MIME types. We host all our stuff on IIS and this comes pretty much ready-rolled with most of the MIME types set up.  For those of you that don't know what a MIME type is; It's a rule which the web server uses to process certain files based on their extension. JPG, for example, is pretty much going to be a picture so the server allows these as binary downloads, whereae ASPX is a server-side page so the MIME type for ASPX runs through an extra process to translate the code into a working web page

Browsers also use the MIME type to decide how to display the pages, or images, and set them up correctly in the browser. application/rss+xml signifies that there is an RSS feed somewhere nearby and the browser will then highlight the Feed button so the user know where to get the feed from and set it up in their favourites

Which brings me nicely on the the problem that this post is meant to remedy.  We were using the jQuery $(document).ready(function(){$.ajax({type: "GET",url: "tim.xml",dataType: "xml", success: function(xml) { stuff to retrieve the xml and the process the node we were interested in.  Worked fine locally using IIS on any browser we threw at it.  However, we had to upload this to a 3rd party server and the "text/xml" MIME type hadn't been set up.  FireFox didn't seem to mind, but IE was throwing it's toy out of the pram and just not playing ball whatsoever.

After much blog and forum digging, we cam across the explanation on the jQuery site : http://docs.jquery.com/API/1.1.1/Ajax

So there you have it; if somethings not behaving as it should, before you change the code, be sure to verify your MIME types are set up as they should be. I initially thought this was an issue with $(document).ready but amending this didn't fix my issue!!

 

 


Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

September 26. 2009 09:53

So there you have it; if somethings not behaving as it should, before you change the code, be sure to verify your MIME types are set up as they should be. I initially thought this was an issue with $(document).ready but amending this didn't fix my issue!!

Tiffany Bracelets

October 3. 2009 07:29

Browsers also use the MIME type to decide how to display the pages, or images, and set them up correctly in the browser. application/rss+xml signifies that there is an RSS feed somewhere nearby and the browser will then highlight the Feed button so the user know where to get the feed from and set it up in their favourites

games

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

September 3. 2010 14:00

Calendar

September 2010
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

Tags