关于Ajax客户端和服务器PHP交互的返回值有关问题

关于Ajax客户端和服务器PHP交互的返回值问题
我的初始想法是这样的,一个页面上面,点击一个链接,更新指定区域的内容。如:点击左边div的导航栏,更新右边div的主体内容。
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>交互测试</title>
<script>
var xmlhttp=null;
if(window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
function clicka(){
   xmlhttp.open('GET','index.php?a=1',true);

      xmlhttp.onreadystatechange=function()
     {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
          {
                document.getElementById("a").innerHTML=xmlhttp.responseText;
           }
      }
xmlhttp.send();
}

</script>
</head>

<body>
<a id="a" onclick="clicka()">点击这里</a>
    <?php
if($_GET[a])
echo "已经点击a标签";
?>
</body>
</html>


虽然触发了PHP代码,但是responseText的返回值是整个HTML文件,相当于在a标签那里又重复载入了一次HTML。
试着修改document.getElementById("a").innerHTML这里获得的数据,但又不触发PHP代码了。
------解决方案--------------------
    <?php
        if($_GET[a]){
            echo "已经点击a标签";
die();
}
    ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>交互测试</title>
<script>
    var xmlhttp=null;
    if(window.XMLHttpRequest)
        xmlhttp=new XMLHttpRequest();
    function clicka(){
       xmlhttp.open('GET','index.php?a=1',true);
 
      xmlhttp.onreadystatechange=function()
     {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
          {
                document.getElementById("a").innerHTML=xmlhttp.responseText;
           }
      }
    xmlhttp.send();
}
         
</script>
</head>
 
<body>
    <a id="a" onclick="clicka()">点击这里</a>

</body>
</html>


php代码放最前面,并且结束输出