Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass an array as url parameter and redirect to new page

I want to pass an array as url GET parameter and redirect to new page. I don't know how to pass an array with window.location.href. Is there any way in Ajax to redirect to new page with array as parameter(with or without window.location.href) or is there any other function for redirecting to other page in which I can pass an array as parameter from the front-end.

like image 557
Utkarsh Garg Avatar asked Dec 13 '25 05:12

Utkarsh Garg


1 Answers

with jQuery $.param function you can convert array to http query

var data = {myArr: [1,2,3,4,5]};
console.log("index.php?" + $.param(data));    
// index.php?myArr%5B%5D=1&myArr%5B%5D=2&myArr%5B%5D=3&myArr%5B%5D=4&myArr%5B%5D=5
like image 91
Peter Avatar answered Dec 14 '25 18:12

Peter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!