Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE7 & jquery ajax XML: permission denied on local xml file

$('.upload').change(function () {
    var $container = $('#container');
    $container.find('input:checkbox, input:text, select').val('');

    var $thisUpload = $(this);
    var path = 'file:///' + $thisUpload.val().replace(/\\/g, "/");

    $.ajax({
        url: path,
        dataType: 'xml',
        success: function (data) {
        },
        error: function (request, status, error) {
            if (error.message == 'Permission denied') {
                //this is where i end up
            }
        }
    });
});

I know that a "blocked" file can cause this error in IE:

http://webactivedirectory.files.wordpress.com/2011/10/unblockfile.png

However, this file is not blocked. And it is located next to my .html file containing the code above.

What could possibly cause the "permission denied". I highly doubt this is due to the same origin policy.

Any help is MUCH appreciated. Thanks

Edit: This only occurs on my windows xp computer using ie7. Ie7-mode in win7 works well.

Edit #2: This only occurs for xml files which are downloaded as mail attachments.

like image 635
Johan Avatar asked Aug 09 '12 09:08

Johan


4 Answers

It sounds like you are facing the same issue as this existing post jQuery AJAX problem in IE7 (possibly other versions as well) , in which it was solved by writing the code to make the ajax call without using jQuery (created XMLHttpObject, onreadystatechange, etc) and using jQuery to parse the XML.

like image 34
Brad Werth Avatar answered Oct 06 '22 19:10

Brad Werth


You can't access local files like that through AJAX for obvious security reasons.

Note that the file:/// protocol points to the local file system of the client machine that is executing the code.

If the file is on your server, you should be able to revise your path so as to point to the server location.

like image 33
David Hedlund Avatar answered Oct 06 '22 20:10

David Hedlund


You say that this only occurs for xml files which are downloaded as mail attachments and only on win xp. Maybe some antivirus app or your e-mail client blocks xml attachments, do you download attachments via WWW client or some desktop client ?

like image 173
el vis Avatar answered Oct 06 '22 18:10

el vis


just remove file:/// and give the path itself. It means give path/filename.xml

like image 36
paripurna Avatar answered Oct 06 '22 19:10

paripurna