由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 问个node.js的问题
相关主题
Node.js 有用过的么 什么评价这两个地方是否需要typename?
C# HtmlElement.InvokeMember at Amazon.com请教 一个c++ lambda function 的问题
node.js里面,哪些操作用http,哪些用websocket(tcp) ?golang的reflection
谁知道这个嵌套的Python if 是啥意思?【求教】投票机编写的简单方法
Nodejs socket.io emit看不懂any php experts?
请教一下:Javascript callback not workingQ: 2 submit buttons in 1 page (转载)
请问在ASP.net中用Javascript的一个问题Why C++11 introduce "decltype" and "auto"?
一个简单得java程序,java内存问题请教大牛
相关话题的讨论汇总
话题: post话题: function话题: type话题: body
进入Programming版参与讨论
1 (共1页)
g***l
发帖数: 2753
1
学着自己建一个node.js的web server,用来接收post过来的数据,发现同一个post在
submit以后,nodejs server有时间能收到,有时间根本收不到,用inspector查了一下
,Network里面也看不见这个post的动作,但是log显示所有的form.submit()都已经执
行了。无论是form还是node.js这边都没有报错。请问如何查出这个bug?
贴一下server的code,就是从网上抄的很简单的。
http = require('http');
fs = require('fs');
server = http.createServer(function(req, res) {
if (req.method == 'POST') {
console.log("POST");
var body = '';
req.on('data', function(data) {
body += data;
});
req.on('end', function() {
console.log("Body: " + body);
});
req.on('error', function(err) {
console.log("****************************************");
console.error(err.stack);
});
//res.writeHead(200, { 'Content-Type': 'text/html' });
res.writeHead(204, {});
res.end('post received');
} else {
console.log("GET");
var html = fs.readFileSync('index.html');
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(html);
}
});
port = 6789;
host = '127.0.0.1';
server.listen(port, function() {
console.log('Listening at http://localhost:%s', port);
});
g***l
发帖数: 2753
2
贴一下页面代码,请点击附件,可以放大观看。谢谢了。

【在 g***l 的大作中提到】
: 学着自己建一个node.js的web server,用来接收post过来的数据,发现同一个post在
: submit以后,nodejs server有时间能收到,有时间根本收不到,用inspector查了一下
: ,Network里面也看不见这个post的动作,但是log显示所有的form.submit()都已经执
: 行了。无论是form还是node.js这边都没有报错。请问如何查出这个bug?
: 贴一下server的code,就是从网上抄的很简单的。
: http = require('http');
: fs = require('fs');
: server = http.createServer(function(req, res) {
: if (req.method == 'POST') {
: console.log("POST");

s***o
发帖数: 2191
3
"Network里面也看不见这个post的动作", 应该是没有真正submit出去吧。可以进一步
用onsubmit测试一下:
form ... onsubmit="submitIt()"
....
function submitIt(){
alert("xxx")
...

【在 g***l 的大作中提到】
: 学着自己建一个node.js的web server,用来接收post过来的数据,发现同一个post在
: submit以后,nodejs server有时间能收到,有时间根本收不到,用inspector查了一下
: ,Network里面也看不见这个post的动作,但是log显示所有的form.submit()都已经执
: 行了。无论是form还是node.js这边都没有报错。请问如何查出这个bug?
: 贴一下server的code,就是从网上抄的很简单的。
: http = require('http');
: fs = require('fs');
: server = http.createServer(function(req, res) {
: if (req.method == 'POST') {
: console.log("POST");

g***l
发帖数: 2753
4
onsubmit是没有被触发。为什么会post不出去呢? 没有任何的错误信息啊。

【在 s***o 的大作中提到】
: "Network里面也看不见这个post的动作", 应该是没有真正submit出去吧。可以进一步
: 用onsubmit测试一下:
: form ... onsubmit="submitIt()"
: ....
: function submitIt(){
: alert("xxx")
: ...

s***o
发帖数: 2191
5
try:
document.forms[index] or
document.getElementById(id).submit() or
change "id" to "name" (
具体syntax我记不清了,不过感觉问题可能在document.forms[id]上

【在 g***l 的大作中提到】
: onsubmit是没有被触发。为什么会post不出去呢? 没有任何的错误信息啊。
g***l
发帖数: 2753
6
不是这个问题。我把第一个form改成
http://10.4.4.222:6789" onsubmit="myFunction()">
"jasmineStarted">


然后JScode改成下面的还是发不出去。form的值是被更新了,console.log也触发了,
就是提交不了。
jasmineStarted: function(suiteInfo) {
console.log('Running suite with ' + suiteInfo.totalSpecsDefined);
document.getElementById("jasmineStarted_totalSpecsDefined").
value = suiteInfo.totalSpecsDefined;
document.getElementById("jasmineStartedForm").submit();
console.log("form jasmineStarted submitted");
},

【在 s***o 的大作中提到】
: try:
: document.forms[index] or
: document.getElementById(id).submit() or
: change "id" to "name" (
: 具体syntax我记不清了,不过感觉问题可能在document.forms[id]上
g***l
发帖数: 2753
7
我如果加一个提交的button,在页面上点击就可以提交。


value=

【在 g***l 的大作中提到】
: 不是这个问题。我把第一个form改成
: http://10.4.4.222:6789" onsubmit="myFunction()">
: : "jasmineStarted">
:
:
: 然后JScode改成下面的还是发不出去。form的值是被更新了,console.log也触发了,
: 就是提交不了。
: jasmineStarted: function(suiteInfo) {

s***o
发帖数: 2191
8
那大概就是jasmine在搞鬼了

value=

【在 g***l 的大作中提到】
: 不是这个问题。我把第一个form改成
:
http://10.4.4.222:6789" onsubmit="myFunction()">
: : "jasmineStarted">
:
:

: 然后JScode改成下面的还是发不出去。form的值是被更新了,console.log也触发了,
: 就是提交不了。
: jasmineStarted: function(suiteInfo) {

n****j
发帖数: 1708
9
Host = 127.0.0.1,只监听 localhost,10.x.x.x 的数据包收不到

【在 g***l 的大作中提到】
: 学着自己建一个node.js的web server,用来接收post过来的数据,发现同一个post在
: submit以后,nodejs server有时间能收到,有时间根本收不到,用inspector查了一下
: ,Network里面也看不见这个post的动作,但是log显示所有的form.submit()都已经执
: 行了。无论是form还是node.js这边都没有报错。请问如何查出这个bug?
: 贴一下server的code,就是从网上抄的很简单的。
: http = require('http');
: fs = require('fs');
: server = http.createServer(function(req, res) {
: if (req.method == 'POST') {
: console.log("POST");

n****j
发帖数: 1708
10
这 client 写得太乱了,通常用 jquery.post,不需要这么多 form tag

【在 g***l 的大作中提到】
: 贴一下页面代码,请点击附件,可以放大观看。谢谢了。
T*******x
发帖数: 8565
11
看起来挺整齐的。

【在 n****j 的大作中提到】
: 这 client 写得太乱了,通常用 jquery.post,不需要这么多 form tag
c*********e
发帖数: 16335
12

可能lz的wifi不能连到10.x.x.x去。

【在 n****j 的大作中提到】
: Host = 127.0.0.1,只监听 localhost,10.x.x.x 的数据包收不到
1 (共1页)
进入Programming版参与讨论
相关主题
java内存问题请教大牛Nodejs socket.io emit看不懂
珍惜生命,远离 R 和 Go请教一下:Javascript callback not working
python 3.5 typing hint普及之後 python真要統治世界了。请问在ASP.net中用Javascript的一个问题
cgi测试newbee问题一个简单得java程序,
Node.js 有用过的么 什么评价这两个地方是否需要typename?
C# HtmlElement.InvokeMember at Amazon.com请教 一个c++ lambda function 的问题
node.js里面,哪些操作用http,哪些用websocket(tcp) ?golang的reflection
谁知道这个嵌套的Python if 是啥意思?【求教】投票机编写的简单方法
相关话题的讨论汇总
话题: post话题: function话题: type话题: body