<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>jquery js 实例代码</title>
<script language="网页特效">
function getjsfile(url, callback){
var xh = window.xmlhttprequest ? new xmlhttprequest : new activexobject('msxml2.xmlhttp');
xh.open('get',url,true);
xh.onreadystatechange = function(){
if(xh.readystate == 4 && xh.status == 200){
if(window.execscript) window.execscript(xh.responsetext);
else eval.call(window, xh.responsetext);
eval(callback)();
}
}
xh.send('');
}
//jquery异步调用天气$.ajax({type:"get", url: "http://m.weather.com.cn/data/101210401.html", datatype: "html",
success: function(json){
alert(json);
var t = '('+json+')';
alert(t);
var result = eval(t);
//var result = eval("{" + json + "}");
//alert(json.responsetext);
alert(result);
$("#weather").append(result.weatherinfo.city+' <img src=https://.oss-cn-hangzhou.aliyuncs.com/erro.html/>'+' <img src=https://.oss-cn-hangzhou.aliyuncs.com/erro.html/> '+result.weatherinfo.weather1+' '+ result.weatherinfo.temp1);
}
});方法三
function page_init() {
try {
$.get("http://fff.ff.com/responsevalue.aspx?cam_id=novell20100608&msg={count}", null, getcallback, 'json');
} catch (e) {}
}
function getcallback(response) {
if (typeof (response) != "object") {
$('#persons').html('0');
return false;
}
if (response.error == 1) {
//alert(response.msg);
$('#persons').html(response.msg);
return;
}}
调用方法:
$(document).ready(
function() {
page_init();
});</script>
</head><body>
</body>
</html>