如何从Header中检索表单数据信息

时间:2018-06-03 04:10:17

标签: jquery angular

我有一个angular2 +页面从支付页面返回,其中包含表单数据标题中的状态信息,我如何在angular2中检索此信息

在asp.net中很容易通过Request.form [" Key"],在angular / Jquery应用程序中如何实现同样的东西

以下是获取的信息

formdata information of Header

enter image description here

2 个答案:

答案 0 :(得分:0)

这可以使用HttpInterceptor完成(如果需要修改并记录请求)

@Injectable()
export class MyHttpInterceptor implements HttpInterceptor {
    constructor() {}

    intercept(req: HttpRequest < any > , next: HttpHandler): Observable < HttpEvent < any >> {

        console.log("intercepted request ... ");

        // Clone the request to add the new header.
        const authReq = req.clone({
            headers: req.headers.set("headerName", "headerValue")
        });

        console.log("Sending request with new header now ...");

        //send the newly created request
        return next.handle(authReq)
            .catch((error, caught) => {
                //intercept the respons error and displace it to the console
                console.log("Error Occurred");
                console.log(error);
                //return the error to the method that called it
                return Observable.throw(error);
            }) as any;
    }
}

更多信息herehere

答案 1 :(得分:0)

虽然有角度(客户端javascript)浏览器不能将这些数据提供给javascript,但您无法获得发布表单数据,但您可以使用node.js(服务器端javascript)或Asp。 Net接收它并重定向到您的角度页面

  1. 将付款页面重定向网址设置为您的服务器
  2. 在您的服务器中保存付款信息
  3. 由您的服务器重定向到您的角度页面,并传递您的网址中的orderNumber或其他字段,让您可以从您的服务器获取高级信息
  4. 使用angular发送http.get或http.post,其orderNumber为prev步骤到您的服务器
  5. 接收付款信息并执行某些操作
  6. enter image description here

相关问题