通過設定ie的通過跨域訪問資料來源,來訪問本地服務
1、首先設定通過域訪問資料來源
設定通過域訪問資料來源
2、javascript指令碼ajax使用本地服務登入(評價,人證的類似)介面
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
var ss=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://127.0.0.1:27100/Terminal?t=Login&name=員工1",false);
xmlhttp.send();
}
</script>
</head>
<body>
<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">請求資料</button>
<div id="myDiv"></div>
</body>
</html>