第一個重點先判斷是IE或firefox瀏覽器再呼叫不同的方法
xmlhttp.open後面要帶入傳到哪個網頁以及丟過去的參數

function showmsg(x)
{

if (window.XMLHttpRequest)
  xmlhttp = new XMLHttpRequest();
    else if (window.ActiveXObject)
 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

if ( xmlhttp )
{  
   xmlhttp.onreadystatechange = showtxtf;
   xmlhttp.open("get","readdb.jsp?ids="+x,true);
   xmlhttp.send(null)
}
}




第二個重點
傳回時接收是否成功的訊息
如果成功就寫入網頁中定義的span

function showtxtf()
{

if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 )   
 document.getElementById("showtxt").innerHTML =xmlhttp.responseText;
 
}
arrow
arrow
    全站熱搜

    ROACH 發表在 痞客邦 留言(0) 人氣()