<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="HandheldFriendly" content="true"/>
<meta name="MobileOptimized" content="320"/>
<title>XMLHttpRequest</title>
<script type="text/javascript">
var xhr=null;
function testXHR(){
if(xhr){
return;
}
xhr=new plus.net.XMLHttpRequest();
xhr.onreadystatechange=function(){
console.log("onreadystatechange: "+xhr.readyState);
}
xhr.open( "GET", "192.168.1.5" );
xhr.send();
}
// 获取所有HTTP响应Content-Type信息
function getResponseHeader(){
if(xhr){
console.log(xhr.getResponseHeader("Date"));
}
}
</script>
</head>
<body>
<button onclick="testXHR()">XMLHttpRequest</button><br/>
<button onclick="getResponseHeader()">getResponseHeader</button>
</body>
</html>
0 个回复