最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Pass a JSON object as a parameter with an url? - Stack Overflow

programmeradmin2浏览0评论

I'm using the below url to pass few parameters along with the url. But I want to pass an JSON object instead of params.

So any solution or suggestion from your end.

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"); 

I am using angular js 1.5 also tell me the what I need to do in the state provider.

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

I want to pass 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"

I'm using the below url to pass few parameters along with the url. But I want to pass an JSON object instead of params.

So any solution or suggestion from your end.

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"); 

I am using angular js 1.5 also tell me the what I need to do in the state provider.

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

I want to pass 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"

Share Improve this question edited Jul 27, 2017 at 10:18 Joydeep Roy asked Jul 27, 2017 at 10:03 Joydeep RoyJoydeep Roy 651 gold badge1 silver badge11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

Just pass it as a string, after encoding it:

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

评论列表(0)

  1. 暂无评论