|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script>
- <title>我的HTML JS笔记</title>
- </head>
- <body>
-
- <h1 align="center">我的 html js 相关笔记</h1>
- <a href="test.html" target="_blank">自动循环显示图片(查看效果)</a>
- <button onclick="readtxt()" >查看源码</button>
- <p>
- <p><textarea id="txt" name="result" cols="60" rows="30" value="">
- <script>
- var jstxt = document.getElementById('txt');
- function readtxt()
- {
- alert(xhr.status);
- var xhr = new XMLHttpRequest();
- xhr.open('get','test.html',true);
- xhr.send();
- alert(xhr.status);
- xhr.onreadystatechange = function ()
- {
- alert(xhr.status);
- if (xhr.readyState == 4 && xhr.status == 200)
- {
- alert("请求服务器数据成功且返回数据成功!");
- jstxt.innerHTML = xhr.responseText;
- };
- };
- };
- </script>
- </body>
- </html>
复制代码
2个错误:
HTML1300: 进行了导航。myhtml.html (1,1)
HTML1501: 文件结尾不符合要求。myhtml.html (36,8)
0: 'readtxt' is not defined myhtml.html (11,18)
这样试试:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script>
- <title>我的HTML JS笔记</title>
- </head>
- <body>
- <script>
- var jstxt = document.getElementById('txt');
- function readtxt()
- {
- var xhr = new XMLHttpRequest();
- alert(xhr.status);
- xhr.open('get','test.html',true);
- xhr.send();
- alert(xhr.status);
- xhr.onreadystatechange = function ()
- {
- alert(xhr.status);
- if (xhr.readyState == 4 && xhr.status == 200)
- {
- alert("请求服务器数据成功且返回数据成功!");
- jstxt.innerHTML = xhr.responseText;
- };
- };
- };
- </script>
- <h1 align="center">我的 html js 相关笔记</h1>
- <a href="test.html" target="_blank">自动循环显示图片(查看效果)</a>
- <button onclick="readtxt()" >查看源码</button>
- <p>
- <p><textarea id="txt" name="result" cols="60" rows="30" value="">
- </body>
- </html>
复制代码
|
|