这是我的代码,也没有报错,就是页面看不到内容怎么回事?
这是我的代码,也没有报错,就是页面看不到内容怎么回事?
var http=require("http");
var queryString=require("querystring");
var postDate=queryString.stringify({
"content":"下期的课程开始了吗?",
"cid":348
})
var options={
hostname:"www.imooc.com",
path:"/course/docomment",
method:"POST",
port:80,
headers:{
'Accept':'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8',
'Connection':'keep-alive',
'Content-Length':postDate.length,
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie':'PHPSESSID=mkmc85eiuplhkktc2pps2bh531; imooc_uuid=8ffc2ce9-af5b-4de6-bb5f-a5d535b8d3e2; imooc_isnew=1; imooc_isnew_ct=1492411843; loginstate=1; apsid=E0ZDhhZmVmZWRkZGQ5ZTQ1ZWFlMjAxYjM0MmM1ZjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANDIzMDY0NQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADM2ODI3MDc2ZmJiMTkxM2IyYTY1MzYwNTc2NzZlN2M0JWb0WCVm9Fg%3DMD; channel=491b6f5ab9637e8f6dffbbdd8806db9b_phpkecheng; IMCDNS=0; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1492411839,1492411928; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1492416929; cvde=58f465c39ebff-99',
'Host':'www.imooc.com',
'Origin':'http://www.imooc.com',
'Referer':'http://www.imooc.com/comment/348',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'X-Requested-With':'XMLHttpRequest'
}
}
var req=http.request(options,function(res){
console.log('status+'+res.statusCode)
res.on('data',function(chunk){
console.log('正在返回')
})
res.on('end',function(){
console.log('评论完毕')
})
});
req.on('error',function(e){
console.log('error'+ e.message)
});
req.write(postDate);
req.end();