function $(elementId) { //擷取指定id的object
if (document.getElementById) {
return document.getElementById(elementId);
} else if (document.all) {
return document.all[elementId];
} else if (document.layers) {
return document.layers[elementId];
}
}
function XHR(){ //建立XMLHttpRequest對象
var obj;
try{
obj = new XMLHttpRequest();
}catch(e){
var a=['MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','MICROSOFT.XMLHTTP.1.0','MICROSOFT.XMLHTTP.1','MICROSOFT.XMLHTTP'];
for (var i=0;i<a.length;i++){
try{
obj = new ActiveXObject(a[i]);
break;
}catch(e){}
}
}
return obj;
}
function newsList(groupNum) {
$("NewsList").innerHTML = "<img src="loading.gif" align="absmiddle"> <font color='black'>載入標題中……,請稍後……</font>"
var oAjax = XHR();
if(oAjax) {
oAjax.open("post", "Ajax_Example.asp?Show="+groupNum+"&flag="+Math.random(), true);
oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
oAjax.send(null);
// if (oAjax.readyState == 4) {
// showList(oAjax.responseText);
// }
// else {
// alert("擷取失敗!")
// }
oAjax.onreadystatechange = function() {
if (oAjax.readyState == 4) {
if(oAjax.status == 200){
//alert(oAjax.responseText)
showList(oAjax.responseText);
}
else {
alert("擷取失敗!")
}
}
}
}
}