日期:2014-05-16 浏览次数:20704 次
<script type="text/javascript">
var xmlHttp;
//端发送异步的http请求
function createXMLHttpRequest()
{
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
{
//如果用户使用IE,就返回XMLHTTP的ActiveX对象
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
//否则返回一个XMLHttpRequest对象
xmlHttp = new XMLHttpRequest();
}
}
function startRequest()
{
createXMLHttpRequest();
var str = "HELLO";
try
{
str="1";
var url = "http://m.weather.com.cn/data/101020100.html";
xmlHttp.open("GET",url, false);
str="2";
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
str="3";
var result = xmlHttp.responseText;
if(result!=null){
str="31";
}
var json = eval("(" + result + ")");
str="4";
var myCondition = json.weather1;
str="5";
//var myUrl = json.img1+".gif";
var myTemp = json.temp1;
var str1= "<span style='font-size:48px; color:fff'>"+ myTemp +"</span>";
var str2= "<span style='font-family:创艺简魏碑;font-size:48px; color:fff'>"+ myCondition +"</span>";
var str3="<br>";
str=str3+str1+str3+str2;
//document.getElementById("img1").src = myUrl;
xmlHttp.send();
}
catch(exception)
{
alert(str);
}
return str;
}
</script>