Hello Guys,
Is there a way that I can pass a PHP var to the ajax script via an onclick event? I am trying to pass the var - $imgid
Here is my link
PHP Code:
echo '<a href="artists/'.$artist.'/'.$imgid.'.jpg?imgid='.$imgid.'" onclick="loadXMLDoc()" class="thumbnail" ><img src="artists/'.$artist.'/previews/'.$imgid.'.jpg" border="0" /></a>';
Here is the Ajax call
PHP Code:
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","artist_title.php?imgid=<?php echo $imgid?>",true);
xmlhttp.send();
}
</script>
Please advise..
Thanks, Dan