url - How to create query parameters in Javascript? -


is there way create query parameters doing get request in javascript?

just in python have urllib.urlencode(), takes in dictionary (or list of 2 tuples) , creates string 'var1=value1&var2=value2'.

here go:

function encodequerydata(data) {    let ret = [];    (let d in data)      ret.push(encodeuricomponent(d) + '=' + encodeuricomponent(data[d]));    return ret.join('&'); } 

usage:

var data = { 'first name': 'george', 'last name': 'jetson', 'age': 110 }; var querystring = encodequerydata(data); 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -