Re: [問題] 一個 JS 的系統問題
: → fillano:ajax可以在本機操作,但是ff3需要用about:config改權限 01/13 11:57
在下用 IE 在本機實測結果是不行,
Fx 不知道要改哪一個 config,不過如果 IE 不行的話,在下就不考慮了。
放上伺服器的話,IE 和 Fx 都測過可以。
測試檔:
HelloAjaxEx-1.txt
這是非同步請求的回應文字
HelloAjaxEx-1.js
var xmlHttp;
function createXMLHttpRequest() {
if(window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function startRequest() {
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "HelloAjaxEx-1.txt");
xmlHttp.send(null);
}
function handleStateChange() {
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
alert("伺服端回應:" + xmlHttp.responseText);
}
}
}
HelloAjaxEx-1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=Big5" http-equiv="content-type">
<title>Hello! Ajax! Examples...</title>
<script type="text/javascript" src="HelloAjaxEx-1.js"></script>
</head>
<body>
<center><input value="Ajax請求" onclick="startRequest();"
type="button"></center>
</body>
</html>
(↑按下綠色的按鈕執行)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.25.118.142
→
01/15 11:29, , 1F
01/15 11:29, 1F
→
01/15 11:30, , 2F
01/15 11:30, 2F
→
01/15 11:37, , 3F
01/15 11:37, 3F
→
01/15 11:38, , 4F
01/15 11:38, 4F
→
01/15 15:32, , 5F
01/15 15:32, 5F
→
01/15 21:03, , 6F
01/15 21:03, 6F
→
01/15 22:47, , 7F
01/15 22:47, 7F
→
01/15 22:48, , 8F
01/15 22:48, 8F
→
01/15 23:05, , 9F
01/15 23:05, 9F
討論串 (同標題文章)