Can someone please tell me how I can add in the address bar variable to my javascript?
The website address reads: www.example.com/index.php?user=74
and the javascript that needs to include 'user = 74' is:
xmlhttp.open("GET","../profile/" + pageName + ".php",true);
function get_query(){
var url = location.href;
var qs = url.substring(url.indexOf('?') + 1).split('&');
for(var i = 0, result = {}; i < qs.length; i++){
qs[i] = qs[i].split('=');
result[qs[i][0]] = decodeURIComponent(qs[i][1]);
}
return result;
}
xmlhttp.open("GET","../profile/" + pageName + ".php?user=" + get_query()['user'],true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.