Strony

2010-05-11

[jquery][php] $_GET w jQuery

Aby skorzystać z tablicy $_GET w jQuery wystarczy:

function getQueryParams(qs) {
qs = qs.split("+").join(" ");
var params = {};
var tokens;

while (tokens = /[?&]?([^=]+)=([^&]*)/g.exec(qs)) {
params[decodeURIComponent(tokens[1])]
= decodeURIComponent(tokens[2]);
}

return params;
}

var $_GET = getQueryParams(document.location.search);

źródło: http://stackoverflow.com/questions/439463/how-to-get-get-and-post-variables-with-jquery