Search code examples
javascriptajaxcross-domainformsajaxform

Ajax form - image upload | access denied in ie


I'm creating a facebook application, and want to implement an ajax-like picture upload using the jquery form plugin. Everything is ok in chrome/ff but in iexplorer i get the folowing error:

Message: Access Denied   
Line: 349  
Char: 5  
Code: 0  
URI: http://application.my_domain.gr/apps/new_app/js/jquery.form.js 

I am aware of the cross domain issues, but can't understand why this is happening, since all scripts i'm curently using are on the same domain.
Here's how i've done it working in firefox/chrome:

<html>
<head>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.form.js"></script>
</head>
<body>

<form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'>
        <input type="file" name="photoimg" id="photoimg" />
</form>
<div id='preview'>
</div>

<script>
$('#photoimg').bind('change', function() { 
                    $("#preview").html('');
                    $("#preview").html('<img src="img/loader.gif" alt="Upload in progress"/>');
                    $("#imageform").ajaxForm({
                                        target: '#preview',
                                        success:    function() { 
                                                $("#preview img").attr("id", "uploaded_img");
                                        }
                    }).submit();
                                        
            
            });
</script>
</body>
</html>

Any ideas why this is happening?
Thanks in advance.


Solution

  • OK, it's a while since I posted the question, but here's what finally worked for me:

    I just added my domain to "App Domains" in the app's Basic Settings (Basic Info section) and everething worked ok!