前段:html页面
<!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" xml:lang="en">
<head>
<meta name="viewport" content="initial-scale=0.55,width=device-width,minimum-scale=0.1,maximum-scale=2.0"/>
<title>欢迎光临</title>
</head>
<body>
</body>
</html>
<script>
function check()
{
try{
document.getElementsByTagName("head")[0].removeChild(JSONP);
}catch(e){}
JSONP=document.createElement("script");
JSONP.type="text/javascript";
JSONP.src="http://192.168.1.136:9303/test1.php?t="+(new Date).getTime(); ;
document.getElementsByTagName("head")[0].appendChild(JSONP);
}
function nongshang(data)
{
alert(data.err);
alert(data.data);
if(data.err==0)
{
//window.location.href='http://www.baidu.com';
}
}
check();
</script>
后台php页面:
$arr = array("err"=>0,'data'=>100);
$json = json_encode($arr,true);
echo "nongshang(".$json.");";
浙公网安备 33010602011771号