Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.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
Node.js Nodejs中的soapwebservice抛出;Can';t在发送标题后设置标题。”;错误_Node.js - Fatal编程技术网

Node.js Nodejs中的soapwebservice抛出;Can';t在发送标题后设置标题。”;错误

Node.js Nodejs中的soapwebservice抛出;Can';t在发送标题后设置标题。”;错误,node.js,Node.js,Nodejs代码: router.post('/getdata', function(req, res) { xmlhttp.open('POST', webserviceurl, true); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { var xmlString = xml

Nodejs代码:

router.post('/getdata', function(req, res) {
   xmlhttp.open('POST', webserviceurl, true);

   xmlhttp.onreadystatechange = function () {
     if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
          var xmlString = xmlhttp.responseText;

          parser.parseString(xmlString, function(err, xmlresult){
            if(err) throw err
            res.send({result:xmlresult}); 
          });   
        }
     }  //return false;
   }
   // Send the POST request

   xmlhttp.setRequestHeader('Content-Type', 'text/xml');
   xmlhttp.send(args);
});
Jquery代码:

function getWebservicedata(){
    $.ajax({
      type: 'POST',
      data: {id:userid},
      url: '/getdata',
      dataType: 'JSON'
    }).done(function( data ) {
       console.log(data)
    });

}
当将结果从node.js发送到Ajax时,它会在发送后抛出
无法设置头
错误,因为XML请求使用一个send()函数,而node.js使用另一个
send()
函数

Send()
函数发生冲突并抛出错误。

res.Send()执行.end(),因此响应已关闭。我相信你要找的是res.write()。这不是call.end(),请阅读-总结是,这不是向志愿者致辞的理想方式,可能会对获得答案产生反作用。请不要将此添加到您的问题中。但是res.write()不会将xml结果发送回ajax函数。我们怎样才能做到这一点。。有什么想法吗?