I can\'t seem to find an answer to this question.. How can I convert a URL parameters string to JSON in javascript? I mean to ask if there is an in-built function like this
Try use this function:
// Returns an object with elements "name: value" with data ftom URL (the "name=value" pairs)
function getDataUrl(url) {
// From: http://coursesweb.net/javascript/
var url_data = url.match(/\?([^#]*)/i)[1]; // gets the string between '?' and '#'
// separate the data into an array, in case the are multiple pairs name=value
var ar_url_data = url_data.split('&');
// traverse the array, and adds into an object elements name:value
var data_url = {};
for(var i=0; i