Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
正在尝试从express向jquery iframe传输发送响应_Jquery_Node.js_Iframe_Formidable_Jquery Iframe Transport - Fatal编程技术网

正在尝试从express向jquery iframe传输发送响应

正在尝试从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

我正在尝试使用jquery ifram transport和nodejs设置一个简单的文件上传。问题是我一直在捕获错误SecurityError:用origin
阻止一个帧。”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安全性

请在此处阅读更多信息:


在注释中添加了我的cors。A转到命令行并输入start chrome--禁用web安全出现相同错误
app.all('*', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  next();
 });