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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -