正在尝试从express向jquery iframe传输发送响应
我正在尝试使用jquery ifram transport和nodejs设置一个简单的文件上传。问题是我一直在捕获错误SecurityError:用origin正在尝试从express向jquery iframe传输发送响应,jquery,node.js,iframe,formidable,jquery-iframe-transport,Jquery,Node.js,Iframe,Formidable,Jquery Iframe Transport,我正在尝试使用jquery ifram transport和nodejs设置一个简单的文件上传。问题是我一直在捕获错误SecurityError:用origin阻止一个帧。”https://localhost:8081“通过访问源代码为“serverURL”的框架。协议、域和端口必须匹配 下面是我的客户机的ajax代码 var uploadXhr = $.ajax($scope.nodeSocketUrl + '/upload?tenant=qa',{ d
阻止一个帧。”https://localhost:8081“
通过访问源代码为“serverURL”的框架。协议、域和端口必须匹配
下面是我的客户机的ajax代码
var uploadXhr = $.ajax($scope.nodeSocketUrl + '/upload?tenant=qa',{
data: $(':text', form).serializeArray(),
files: $('#presentationFileUpload'),
type: 'POST',
iframe: true,
processData: false,
context: this
});
在这里我只是有一个艰难的时间让这个插件与强大的工作,我想请求被发送回客户端像嘿文件已经上传了这样的东西
form.on('end',function(){
res.header({'content-type': 'text/html'});
res.send('<html><textarea data-type="application/json">{"ok": true, "message": "Thanks so much"}</textarea></html>');
});
你在用快车吗
试试这个:
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});
您需要启用CORS头才能使其正常工作
编辑:
有时您需要配置浏览器。Localhost的行为与实际域不同
使用以下设置启动Chrome:--禁用web安全性
请在此处阅读更多信息:
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});