Javascript 如何仅停止当前页面进程,而不是停止整个NodeJS服务器
这个问题听起来可能很笨拙,因为我不知道如何用语言来表达。请看一看这个例子:Javascript 如何仅停止当前页面进程,而不是停止整个NodeJS服务器,javascript,php,node.js,die,Javascript,Php,Node.js,Die,这个问题听起来可能很笨拙,因为我不知道如何用语言来表达。请看一看这个例子: //PHP <?php die( "The PHP process stops here. The PHP is still running" ); insert_into_database_someinfo(); //This function will not be executed ?> 在PHP中,我认为这与“代码>回音”有一定的可比性,因为一切都在继续。我想输出信息,然后在那里停止
//PHP
<?php
die( "The PHP process stops here. The PHP is still running" );
insert_into_database_someinfo(); //This function will not be executed
?>
在PHP中,我认为这与“代码>回音”<代码>有一定的可比性,因为一切都在继续。我想输出信息,然后在那里停止进程(只是当前请求,而不是整个nodejs服务器)
请告知。插入一个
返回
以停止执行您的函数:
if (nogood) {
req.end( 'This is an output to the browser' );
return;
}
insert_into_database_someinfo();
非常感谢您的快速回复。但是,它不会起作用(或者可能是我的错误)。我试着做
res.end('Email invalid');返回;将_插入_数据库_someinfo()代码>并且它仍在运行。有趣的是,节点中没有等效项。
if (nogood) {
req.end( 'This is an output to the browser' );
return;
}
insert_into_database_someinfo();