AJAX 일기예보 프론트 데스크
5178 단어 AJAX 일기예보 프론트 데스크
<!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 language="JavaScript" type="text/javascript">
function $() {
return document.getElementById(arguments[0])
}
function btnSty(objId,objStyle)
{
$(objId).style.display = objStyle
}
//
function ifodis(){
btnSty('loadifo','none');
}
function settime(a){
setTimeout(a,1000);
}
function loadtime(){
$("loadifo").innerHTML += "."
}
//XML
var xmldoc = false;
function loadurl(n){
// ,
var now=new Date();
var Num=now.valueOf();
//
url = "weather.asp?n="+n+"&id="+Num;
//
xmldoc = false;
//Mozill,Safari XMLHttp
if(window.XMLHttpRequest){
xmldoc = new XMLHttpRequest();
if(xmldoc.overrideMimeType){
xmldoc.overrideMimeType('text/xml');
}
}
//IE XMLHttp
else if(window.ActiveXObject){
try{
xmldoc = new ActiveXObject("Msxml3.XMLHTTP");
}
catch(e){
try{
xmldoc = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
xmldoc = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){}
}
}
}
// XMLHTTP
if(! xmldoc){
return false;
}
// CheckState
xmldoc.onreadystatechange = CheckState;
xmldoc.open('GET',url,true);
xmldoc.send(null);
}
//
function CheckState(){
btnSty('loadifo','')
//
if(xmldoc.readyState == 1){
$("loadifo").innerHTML = " "
}
else if(xmldoc.readyState == 2){
$("loadifo").innerHTML = " "
}
else if(xmldoc.readyState == 3){
$("loadifo").innerHTML = " "
settime(loadtime)
}
else if(xmldoc.readyState == 4){
//HTTP
if(xmldoc.status == 200){
// ID showdiv
$("loadifo").innerHTML = " "
var response = xmldoc.responseText;
settime(ifodis)
$("prolist").innerHTML = response;
}
else{
$("loadifo").innerHTML = " "+xmldoc.statusText+" ";
}
}
}
</script>
<style type="text/css">
<!--
body {
margin: 0px;
padding: 0px;
font-size: 9pt;
}
-->
</style>
</head>
<body onload="loadurl('CHXX0138')">
<div>
<select onchange="loadurl(this.value)">
<option value="CHXX0138" selected="selected"> </option>
<option value="CHXX0097"> </option>
<option value="CHXX0502"> </option>
<option value="CHXX0008"> </option>
<option value="CHXX0116"> </option>
<option value="CHXX0037"> </option>
<option value="CHXX0259"> </option>
<option value="CHXX0165"> </option>
<option value="CHXX0013"> </option>
<option value="CHXX0390"> </option>
<option value="CHXX0049"> </option>
<option value="CHXX0146"> </option>
<option value="CHXX0016"> </option>
<option value="CHXX0110"> </option>
<option value="CHXX0039"> </option>
<option value="CHXX0064"> </option>
<option value="CHXX0448"> </option>
<option value="CHXX0031"> </option>
<option value="CHXX0099"> </option>
<option value="ITXX0042"> </option>
</select>
<span id="loadifo"></span></div>
<div id="prolist"></div>
</body>
</html>