易截截图软件、单文件、免安装、纯绿色、仅160KB

Ajax 错误处理

错误处理
•调用时可以提供一个额外的错误回调函数
•包括超时和服务器端抛出的异常
•超时只能设置在WebService级别
–或者设置在PageMethods对象上
–无法在每个MethodCall时指定
•Sys.Net.WebServiceError
–timedout、message、exceptionType、stackTrace属性
ErrorHandling.asmx Code:
<%@ WebService Language="C#" Class="ErrorHandling" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Threading;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class ErrorHandling : System.Web.Services.WebService
{
[WebMethod]
public int GetDivision(int a, int b)
{
return a / b;
}
[WebMethod]
public int Timeout()
{
Thread.Sleep(5000);
return 0;
}
}
3_ErrorHandling.aspx Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="3_ErrorHandling.aspx.cs" Inherits="_3_ErrorHandling" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="ErrorHandling.asmx" />
</Services>
</asp:ScriptManager>

<input type="button" value="getDivision" onclick="getDivision(5, 0)" />
<input type="button" value="timeout" onclick="timeout()" />

<mce:script language="javascript" type="text/javascript"><!--
function getDivision(a, b)
{
ErrorHandling.GetDivision(a, b, null, failedCallback);
}

function timeout()
{
ErrorHandling.set_timeout(2000);
ErrorHandling.Timeout(null


相关文档:

AJAX中的请求方式以及同步异步的区别请求方式

请求方式,分为GET与POST:
 
GET
 
最为常见的HTTP请求,普通上网浏览页面就是GET。GET方式的参数请求直接跟在URL后,以问号开始。(JS中用window.location.search获得)。参数可以用encodeURIComponent进行编码,使用方式:
 
var EnParam = encodeURIComponent(param);
URL只支持大约2K的长度,即2 ......

FireFox和IE 中 Ajax 同步执行

var Ajax = new Object;
Ajax.Sysch = function(url) {
var req;
var result = "";
//document .write ("hello")
if (window.XMLHttpRequest) {
//代码段1
// 非IE浏览器

req = new XMLHttpRequest();
//alert(req);
//req.setReque ......

基于AJAX服务器推Comet实现

数据表words结构
CREATE TABLE `words` (                                                                           & ......

使用jQuery简化Ajax开发——Ajax开发入门

jQuery是一个可以简化 JavaScript?以及AJAX(Asynchronous JavaScript
+XML,异步Javascript和XML)编程的Javascript库。不同于其他的Javascript库,jQuery有他自己的哲学,使你可
以很简单的编写代码。这篇文章就会带领你见识一下jQuery的哲学,探讨一下他的特性以及功能,并且会做一些ajax的示例,以及如何使用plug-
......

ajax 处理异步刷新中出现的异常

Default3.aspx Code:
<%@Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号