any way to get url parameter that passed to js it self ?
example:
https://xxxxxxx/sample.js?
key
=valuehere
the result i want to get: var key = valuehere
like php, it can be done with $_GET, but how it work it js ?
thanks in advance
Edit:
need to define the key in the js it self
function renderMe () {
var value = getkeyvaluefromURL; // query param stored here
$.ajax({
url: base_url+"/api/render",
method: "POST",
data : { 'command' : 'list', 'key' = value},
dataType: 'JSON',
success: function (data) {
$('#list').html(generateBoxList(data));
},
});
}
so the value need to passed to ajax query when it stored to js url. all is one file js.