Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript POST请求res.重定向()不工作_Javascript_Node.js_Forms_Express_Post - Fatal编程技术网

Javascript POST请求res.重定向()不工作

Javascript POST请求res.重定向()不工作,javascript,node.js,forms,express,post,Javascript,Node.js,Forms,Express,Post,这是我的邮寄路线。当我提交表单时,它基本上只是暂停。正在向服务器发送post,但没有将响应(重定向)发送回客户端 app.post('/signup', function(req, res) { var customer = req.body.customer; var newCustomer = { "first_name": customer.first_name, "last_name": customer.last_name, "email": customer.

这是我的邮寄路线。当我提交表单时,它基本上只是暂停。正在向服务器发送post,但没有将响应(重定向)发送回客户端

app.post('/signup', function(req, res) {
var customer = req.body.customer;
var newCustomer = {
    "first_name": customer.first_name,
    "last_name": customer.last_name,
    "email": customer.email,
    "password": customer.password,
    "phone": customer.phone,
    "address": `${customer.address} ${customer.appt}`,
    "city": customer.city,
    "state": customer.state,
    "zip": customer.zip,
    "country": "US",
    "gateway_type": "PayWhirl Test Gateway",
    "gateway_id": 4133,
    "currency": "USD",
    "metadata": customer.referral
}

paywhirl.Customers.createCustomer(newCustomer, function() {
    if(err) {
        console.log(err);
        res.redirect('/', {err: err});
    } else {
        console.log('customer created!');
        res.redirect('/', {first_name: customer.first_name});
    }
});
})
下面是正在调用的paywhirl函数:

createCustomer: function(data, cb) {
    options.path = "/create/customer";
    options.method = "POST";

    utils.pwPOST(options, data, cb);

},

是否确实正在调用createCustomer回调?您可以添加一个
console.log
来检查可能重复的
console.log()
调用吗?另外,您似乎没有在回调中传递
err
。@ImClarky只传递console.logged,所有内容都被调用。我本来有错误,但把它拿了出来,很抱歉。我想你可能打错了重定向。如果使用两个参数调用它,第一个参数应为状态代码,第二个参数应为url as。是否确实调用了createCustomer回调?您可以添加一个
console.log
来检查可能重复的
console.log()
调用吗?另外,您似乎没有在回调中传递
err
。@ImClarky只传递console.logged,所有内容都被调用。我本来有错误,但把它拿了出来,很抱歉。我想你可能打错了重定向。如果您使用两个参数调用它,第一个参数应该是状态代码,第二个参数应该是url as。