1.helloWorld
例 1.1(testIEFF.htm)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>helloworld</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.ActiveXObject){//ie
alert("we are using microsoft ActiveXObject");
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(){
createXMLHttpRequest();
/*
马克-to-win:onreadystatechange: 指定当readyState属性改变时的事件处理句柄
每当XMLHttpRequest状态改变时,onreadystatechange事件就触发,
actually, the next statement won't be immidiately executed, it just determine that when the status
changes, it will run handleStateChange.
*/
xmlHttp.onreadystatechange = handleStateChange;
/* open()的第一个参数是HTTP请求方式 GET, POST, HEAD 或任何服务器所支持的您想调用的方式.
马克-to-win: it will go to the same webmodule to get "servlet", or
you can xmlHttp.open('GET', 'http://www.example.org/some.file', true);
第二个参数是请求页面的URL. 第三个参数设置请求是否为异步模式.如果是TRUE, JavaScript函数将继续执行,而不等待服务器响应.
这就是"AJAX"中的"A".
ajax当中给出一个helloWorld例子
猜你喜欢
转载自blog.csdn.net/mark_to_win/article/details/88681907
今日推荐
周排行