2

我正在创建一个 facebook 应用程序,并希望使用jquery form plugin实现类似 ajax 的图片上传。在 chrome/ff 中一切正常,但在 iexplorer 中我得到以下错误:

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

我知道跨域问题,但不明白为什么会这样,因为我目前使用的所有脚本都在同一个域上。
以下是我在 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>

任何想法为什么会发生这种情况?
提前致谢。

4

2 回答 2

0

好的,自从我发布问题以来已经有一段时间了,但这是最终对我有用的方法:

我刚刚在应用程序的基本设置(基本信息部分)中将我的域添加到“应用程序域”中,一切正常!

于 2012-12-31T11:59:33.287 回答
-1

如果您从安全页面 (https) 到非安全页面进行 ajax 调用,IE 将显示错误,反之亦然。

确保所有 url、页面 url 和 ajax url 都具有相同的安全性。

于 2012-01-10T22:21:49.733 回答