swaggerking
asked on
Add querystring to Ajax in classic asp
I have a dynamic page that is displaying details based upon a unique ID being passed in my querystring/url parameter. I'm trying to figure out how to add the querystring to the GET Ajax based upon this unique id.
This what I have:
mypage.asp?id=1
<div id="moreDiv"></div>
<div id="foo">
<h3 class="more"><a href="javascript: void(0)" onclick="toggle_visibility ('foo'); loadXMLDoc()"><span>[+]</s pan> view comments</a></h3>
</div>
<script>
function loadXMLDoc()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.X MLHTTP");
}
xmlhttp.onreadystatechange =function( )
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("m oreDiv").i nnerHTML=x mlhttp.res ponseText;
}
else {
document.getElementById("m oreDiv").i nnerHTML=' <img id="centerload" src="ajax-loader.gif">';
}
}
// I tried this without luck
var myquerystring = window.location.search.sub string(1);
xmlhttp.open("GET","commen tsmore.asp ?id=" + myquerystring,true);
xmlhttp.send();
}
</script>
This what I have:
mypage.asp?id=1
<div id="moreDiv"></div>
<div id="foo">
<h3 class="more"><a href="javascript: void(0)" onclick="toggle_visibility
</div>
<script>
function loadXMLDoc()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.X
}
xmlhttp.onreadystatechange
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("m
}
else {
document.getElementById("m
}
}
// I tried this without luck
var myquerystring = window.location.search.sub
xmlhttp.open("GET","commen
xmlhttp.send();
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Them little things will get you! Thanks!
ASKER
My bad. My syntax was wrong. It was displaying "ID=1" instead of what I thought "1".
I changed:
xmlhttp.open("GET","commen
to
xmlhttp.open("GET","commen
and it seems to be working.