Node.js Nodejs中的soapwebservice抛出;Can';t在发送标题后设置标题。”;错误
Nodejs代码: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
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函数。我们怎样才能做到这一点。。有什么想法吗?