Ajax 方法
// ==============================================================================
// Created by Bndy at 10 / 25 / 2007
// Copyright (c) 2007 Bndy, All rights reserved.
// Welcome to my site http : // www.bndy.net
//
// * * * * * * * * * * * * * * * *
// * Q Q : 8 1 7 9 5 7 0 5 *
// * M S N : bndy533@msn.com *
// * Email : bndy533@163.com *
// * * * * * * * * * * * * * * * *
//
// ------------------------------------------------------------------------------
// ajax 相关函数
// ==============================================================================
var xmlHttp;
// 创建XMLHttpRequest对象
function createXMLHttpRequest() {
try {
// FireFox, Opera 8.0 +, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) {
try {
// IE 6.0 +
xmlHttp = new ActiveXObject('MSXML2.XMLHTTP');
}
catch (e) {
try {
// IE 5.5 +
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (e) {
alert('您的浏览器不支持AJAX!');
return false;
}
}
}
}
function SendContent(url, type, data, handleMethod) {
createXMLHttpRequest();
xmlHttp.open(type, url);
xmlHttp.onreadystatechange = function() { postBack(handleMethod); };
xmlHttp.send(data);
}
function postBack(method) {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
//var result = xmlHttp.responseText; // 返回文本或XML
// 相关数据处理
method();
}
else {
alert('the XMLHttpRequest status is ' + xmlHttp.status);
}
}
}
function string2Json(s) {
return eval("(" + s + ")");
}
-- From Bndy.Net


浙公网安备 33010602011771号