jQuery ajax local file access xml

Some users reported that they can not view XML trees from IE, Chrome but can view my demo on the website. This reminds me of  XML security permission issues.

Now the issue has been fixed for IE but not for chrome. Researching on different posts, seems this is a google chrome bug itself.

Latest download [click here]

For jQuery website, it describes the issue as below:

When loading XML files locally, e.g. a CD-ROM etc., the data received by Internet Explorer is plain-text, not text/xml. In this case, use the dataType parameter to load the xml file as text, and parse the returned data within the success  function

$.ajax({
   url: "data.xml",
   dataType: ($.browser.msie) ? "text" : "xml",
   success: function(data){
     var xml;
     if (typeof data == "string") {
       xml = new ActiveXObject("Microsoft.XMLDOM");
       xml.async = false;
       xml.loadXML(data);
     } else {
       xml = data;
     }
     // Returned data available in object "xml"
   }
 });

This block of code has been inserted in my code and fixed.

If anyone knows how to fix on the Chrome, welcome your comment 🙂

Advertisements

3 Comments

  1. I’ve found a way around the issue using a JavaScript/Flash approach. If flash is compiled in the Local Only security sandbox, it has full access to local files. Using ExternalInterface, JavaScript can request a Flash Application to load a file, and Flash can pass the result back to JavaScript.

    You can find my implementation here: https://code.google.com/p/flash-loader/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s