JAVASCRIPT下window.location.href通过url传递参数

1.传递json数组

var data = {

  a: 1,

  b: 'qwert'

};

window.location.href = '/cashflow/reporting?' + $.param(data);

2.nodejs后台解析数据

var url = require('url');

var url_parts = url.parse(request.url,tyrue);

var query = ur_parts.query;

var a = query.a;

var b = query.b;

也可以直接食用this.query获取参数

var query = this.query;

var a = query.a;

var b = query.b;



你可能感兴趣的:(Javascript,Nodejs)