AJAX的基本函数
来源:互联网 发布:excel怎样数据保护 编辑:程序博客网 时间:2024/06/06 02:20
这仅仅是自己的学习笔记,只为记录自己的成长。
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Ajax</title> <script> /*function loadXMLDoc(){ //创建 XMLHttpRequest对象 var xmlhttp; if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); }else{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } } //向服务器发送请求 xmlhttp.open("GET","test1.txt",true); //open(method,url,async) // method: 请求的类型,GET或POST // url:文件在服务器上的位置 // async: true异步,false同步 xmlhttp.send(); }*/ //Callback函数,是一种以参数形式传递给另一个函数的函数 //如果网站上存在多个AJAX任务,那么应该为创建XMLHttpRequest对象编写一个标准的函数,并为 //每个AJAX任务调用该函数。 //该函数调用应该包含url以及发生onreadystatechange事件时执行的任务 function loadXMLDoc(url,cfunc){ if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); }else{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=cfunc; xmlhttp.open("GET",url,true); xmlhttp.send(); } function myFunction(){ loadXMLDoc("test1.txt",function(){ if(xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } }) } </script></head><body> <h2>AJAX</h2> <button type="button" onclick="myFunction()">请求数据</button> <div id="myDiv"></div></body></html>
阅读全文
0 0
- AJAX的基本函数
- 封装好的Ajax调用函数以及基本方法总结
- AJAX的基本段落
- 基本的ajax脚本
- Ajax的基本格式
- AJAX 的基本框架
- Ajax 的基本实现
- Ajax的基本使用
- Ajax的基本用法
- Ajax的基本用法
- Ajax的基本使用
- Ajax的基本了解
- ajax的基本流程
- Ajax的基本理解
- ajax的基本用法
- $.ajax()的基本语法
- 最基本的Ajax简述
- jquery的ajax基本操作
- htttp 请求方式get 和post的区别
- springboot如何测试打包部署
- oracle select非group by的字段
- CAN学习笔记二——瑞萨说明书(待更改)
- 转载-万维网是如何工作的
- AJAX的基本函数
- Docker 学习笔记
- Ubuntu 14.04 安装配置 cairo-dock 实现美化+特效
- 贪吃蛇 Linux C语言 第二次小练手
- 返回函数、匿名函数lambda、偏函数
- SSD: Single Shot MultiBox Detector翻译(包括正式版和预印版)(对原文作部分理解性修改)
- js返回数据:str转换成json方法
- qt 使用 xlsx库操作excel表格
- 对_.template函数的理解