url query builder

build queries for ajax requests

JavaScript

buildQuery = function (params) {
    var pairs = []
    for (var key in params) {
      if (params.hasOwnProperty(key)) {
        pairs.push(key + '=' + params[key]);
      }
    }
    return pairs.length > 0 ? '?' + pairs.join('&') : '';
};


var params = { 

btng: 'google', 
acces: 'p',
access: 'p',
client: 'f_boeken_FISIN_ont',
output: 'xml_no_dtd',
proxystylesheet: 'f_boeken_FISIN_ont',
sort: 'date:D:L:d1',
wc: '200', 
wc_mc: '1',
oe: 'UTF-8',
ie: 'UTF-8',
ud: '1',
exclude_apps: '1',
site: 'c_boeken',
ulang: 'nl',
ip: '10.94.21.116',
entqr: '3'
entqrm: '0&%20requiredfields=afkorting_boek:FISIN2015%7Cafkorting_boek:FISIN2016',
filter: '0',
partialfields: 'afkorting_boek:2015',
getfields: '*'
}; 

document.write("http://10.75.120.36/search" + buildQuery(params));