= =ajax发送的数据在node端怎么获取 在request里面找了半天没找到的说 求救
回复 (10)
W
H
那你贴出代码
H
如果用express,如果是Post 就 req.query, get就 req.body
W
D
H
http.createServer(function(request, response) {
var postData = "";
var pathname = url.parse(request.url).pathname;
request.setEncoding("utf8");
request.addListener("data", function(postDataChunk) {
postData += postDataChunk;
});
request.addListener('end', function(){
info = querystring.parse(postData);
//console.log(info);
});
}).listen(8888);
W
引用 hadeshttp.createServer(function(request, response) { var postData = ""; var pathname = url.parse(requ...
$.ajax({ type: 'POST', data: { username: 1231, password: 42141 }, url: 'http://localhost:8080/test', dataType: 'json', success: function (data) { console.log(data) } });
我用jquery的ajax发送发现进不去end事件 而且data事件只进入一次postDataChunk居然是... = =这是怎么回事啊
W
引用 hadeshttp.createServer(function(request, response) { var postData = ""; var pathname = url.parse(requ...
function test(response, request) { var postData = ""; request.addListener("data", function(postDataChunk) { postData += postDataChunk; }); request.addListener('end', function(){ info = querystring.parse(postData); console.log(info); response.writeHead(200); response.end(info); }); } 服务端改成这样的 不知道哪里错了
W
引用 hexie如果用express,如果是Post 就 req.query, get就 req.body
@dengqiao = =是吗 ... 不是很想用express 而且他也是框架吧 他能做到的原版node也可以吧
W
引用 hadeshttp.createServer(function(request, response) { var postData = ""; var pathname = url.parse(requ...
0.0 啊啊 发现了 是调试模式估计断点的时候end事件结束了 然后就卡在那边了 搞定了 谢谢
参与回复
登录后即可参与回复。登录