Created
May 22, 2015 11:53
-
-
Save mrroot5/b5b4523703e50a3dd51e to your computer and use it in GitHub Desktop.
Array to URL, convierte un array al query de una url . Devuelve los parámetros de URL en un string
From http://stackoverflow.com/questions/4297765/make-a-javascript-array-from-url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ArrayToURL(array) { | |
var pairs = []; | |
for (var key in array) | |
if (array.hasOwnProperty(key)) | |
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(array[key])); | |
return pairs.join('&'); | |
} | |
var urlQuery = ArrayToURL({name1: '"text1" & "text2"', nam2: 'val'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment