返回200,但是评论却没有看见新增,求解

var http = require('http');

var querystring = require('querystring');//把对象序列化


var postData = querystring.stringify({

'content':'12345',

'cid':348

});


var options = {

hostname:'www.imooc.com',

port:80,

path:'/course/docomment',

meth:'POST',

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':postData.length,

        'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',

        'Cookie':'imooc_uuid=f81665e5-11b0-41eb-9a31-07a5bb5a41e0;imooc_isnew_ct=1457316482;IMCDNS=0;loginstate=1;apsid=gzNTc0NzdjMGM1NGU4N2JkNDE5MWJlNTY0MTkzYjMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjczMzgyMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxMjU5MDMxMDFAcXEuY29tAAAAAAAAAAAAAAAAAAAAADFiODUxNzgyZjg3YmI4Y2ZiNGY2OGNlYjExNmVlNmZln%2BLcVp%2Fi3FY%3DZj;last_login_username=125903101%40qq.com;bdshare_firstime=1457935399282;PHPSESSID=mmgrt2fjfdr85k7pfigdjha856;jwplayer.qualityLabel=è¶æ¸;jwplayer.mute=false;jwplayer.volume=100;imooc_isnew=2;cvde=56e8abaf0b785-76;Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1457915837,1457935981,1458001811,1458088818;Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1458111895',

        'DNT':'1',

        'Host':'www.imooc.com',

        'Origin':'http://www.imooc.com',

        'Referer':'http://www.imooc.com/comment/348',

        'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko)         Chrome/48.0.2564.97 Safari/537.36',

        'X-Requested-With':'XMLHttpRequest',

}

};




var req = http.request(options,function  (res) {

console.log('status:'+res.statusCode);//网络请求状态码

     console.log('headers:'+JSON.stringify(res.headers));


     res.on('data',function  (chunk) {

      console.log(Buffer.isBuffer(chunk));

      console.log(typeof chunk); 

     });


     res.on('end',function  () {

      console.log('评论完毕!');

     });


    });

     req.on('error',function  (e) {

      console.log('Error:'+e.message); 

     }) ;

     req.write(postData);

     req.end();



http://img.mukewang.com/56e910ac00010e9506620210.jpg

慕神1332585
浏览 1420回答 1
1回答

慕用0418482

返回200代表请求成功,还要看有没有返回值
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Node.js