I always use this.
if (window.location.href != 'search.php') {//get the current url
window.location.href = 'search.php' //redirect
}
Try any of these
- alert(document.URL)
- alert(Window.location.href)
- alert(document.location.href)
- alert(window.location.pathname)
for creating dropdown with links -:Put this in the success part of your ajax
var data=JSON.parse(xmlhttp.responseText);
var alldata;
for(var i=0;i< data.length;i++)
{
alldata += "<a id='some_id' onclick='myFunction(this.id);' href='whatever#' class='link'>"+data[i][0]+"</a><hr>";
}
//data[i][0]-->this depends on your json text.
document.getElementById('your_input_field_id or div_id').innerHTML = alldata;