用iframe跨域上传图片,怎样接收返回的json数据,目前有一个警告提示 Resource interpreted as Document but transferred with MIME type application/json: "http://up.qiniu.com/".
//构造一个隐藏的iframe,把表单放到iframe中提交,实现跨域post表单
function btnSubmit(){
//构造iframe
var iframe = document.createElement("iframe");
iframe.name = "ActionFrame";
iframe.id = "ActionFrame";
iframe.style="display:none"; //设置隐藏该iframe
document.body.appendChild(iframe); //构造一个对象。插入页面中。
//开始提交
var MyForm = document.getElementById("upLoadPortrait");
MyForm.target = "ActionFrame"; //让表单在iframe中提交
MyForm.submit();//执行提交。
alert(document.getElementById('ActionFrame').contentWindow.document.toString());
}
返回的响应头不要设置成application/json,否则IE浏览器直接出问题。
看看这里http://blog.csdn.net/wangzuxi/article/details/43966357