如何使用url将JSON对象作为参数传递?

时间:2017-07-27 10:03:15

标签: javascript url httprequest httpresponse

我使用以下网址传递几个参数和网址。但我想传递一个JSON对象而不是params。

所以你的任何解决方案或建议。

javascript:void window.open("http://173.229.213.72:9000/index.html#/myurl/seeallmyassets/**param_1/param_2**"%2C""%2C"toolbar=no%2Clocation=no%2Cdirectories=no%2Cstatus=no%2Cmenubar=no%2Cscrollbars=no%2Cresizable=1%2Ccopyhistory=no%2Cwidth=1050%2Cheight=750%2Ctop=42%2Cleft=195"); 

我正在使用angular js 1.5也告诉我在状态提供程序中需要做什么。

$ stateProvider.state(' myurl',{                  url:' / test /:param_1 /:param_2 /:param_3',          templateUrl:' common / templates / myUrl.html',           控制器:' myCtrl' });

我想传递request = {                           param_1:abc,                           param_2:def,                           param_1:ghi,                           param_2:jkl,                           param_1:mno,                           param_2:pqr,                           param_1:stv,                           param_2:uvw,                           param_1:xyz,                           param_2:qwe                            }; " http://173.229.213.72:9000/index.html#/myurl/seeallmyassets/:request"

1 个答案:

答案 0 :(得分:0)

在编码后将其作为字符串传递:

var uri = "http://173.229.213.72:9000/index.html#/myurl?jsonObj={'property1':'val1', 'property2':54}";
var encodedUri = encodeURI(uri)
window.open(encodedUri );