Ajax框架
var XmlHttp;
var PathUrl;
function createXmlHttp() {
if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
}
function goAjax() {
XMLHttpRequest = createXmlHttp();
XMLHttpRequest.onreadystatechange = window[funName];
XMLHttpRequest.open("POST", PathUrl, true);
XMLHttpRequest.send(null);
}
function goAjaxMethod(funName, path) {
PathUrl = path;
if (goAjaxMethod.length < arguments.length) {
PathUrl = PathUrl + "?";
for (var index = goAjaxMethod.length; index < arguments.length; index = index + 2) {
if (index = goAjaxMethod.length) {
PathUrl = PathUrl + arguments[index] + "=" + encodeURIComponent(arguments[index + 1]);
}
else {
PathUrl = PathUrl + "&" + arguments[index] + "=" + encodeURIComponent(arguments[index + 1]);
}
}
}
goAjax(funName);
}
function requestText() {
return XMLHttpRequest.responseText;
}
function isSuccess() {
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
&nbs
相关文档:
刚开始学Ajax,看到很多网上的代码都用Get方法提交参数,Tomcat默认ISO编码实在是让人头痛,对付乱码我都是用过滤器做字符编码过滤的,Get方法过滤器监听不到,所以我一直喜欢使用Post方法,下面对Ajax Get和Post方法做一对比
GET:
<mce:script type="text/javascript"><!--
var xmlHttpRequest;
......
ajax全称Asynchronous JavaScript and Xml ,异步传输。
异步传输是面向字符的传输,它的单位是字符;而同步传输是面向比特的传输,它的单位是帧,它传输的时候要求接受方和发送发的始终保持一致的。
异步传输是将比特分成小组来进行传输。一般每个小组的一个8位字符,在每个小组的 ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for Commen ......
错误处理
•调用时可以提供一个额外的错误回调函数
•包括超时和服务器端抛出的异常
•超时只能设置在WebService级别
–或者设置在PageMethods对象上
–无法在每个MethodCall时指定
•Sys.Net.WebServiceError
–timedout、message、exceptionType、stackTrace属性
ErrorHandling.a ......