Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
Javascript navigator.sendBeacon数据发送到服务器_Javascript_Json_Performance_Server - Fatal编程技术网

Javascript navigator.sendBeacon数据发送到服务器

Javascript navigator.sendBeacon数据发送到服务器,javascript,json,performance,server,Javascript,Json,Performance,Server,我正在尝试收集数据并将其发布到服务器,但是 当我试图发布JSON.stringify(JSON数组)时,在服务器端我没有收到帖子 如果im只发送json数组,那么im将获得post(无法解析它) 我找了很多东西想找到答案, 尝试使用cors。。。 例如: var customParser = bodyParser.json({type: function(req) { return req.headers['Content-Type'] === '*/*; charset=UTF-8'

我正在尝试收集数据并将其发布到服务器,但是

当我试图发布JSON.stringify(JSON数组)时,在服务器端我没有收到帖子

如果im只发送json数组,那么im将获得post(无法解析它)

我找了很多东西想找到答案, 尝试使用cors。。。 例如:

 var customParser = bodyParser.json({type: function(req) {
    return req.headers['Content-Type'] === '*/*; charset=UTF-8';
  }});

  app.post('/rum', customParser, function(req, res){
    console.log(req.body);
    console.log(JSON.parse(req.body));
    ramData.addData(JSON.parse(req.body), function (err, res) {});
  });

任何帮助?

暂时禁用sendBeacon内容类型-未捕获的DomeException:无法在“导航器”上执行“sendBeacon”:暂时禁用带有Blob的sendBeacon(),该Blob的类型不是内容类型请求标头的任何CORS safelisted值。有关详细信息,请参阅

 var customParser = bodyParser.json({type: function(req) {
    return req.headers['Content-Type'] === '*/*; charset=UTF-8';
  }});

  app.post('/rum', customParser, function(req, res){
    console.log(req.body);
    console.log(JSON.parse(req.body));
    ramData.addData(JSON.parse(req.body), function (err, res) {});
  });