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
Ïà¹ØÎĵµ£º
load(url[,data][,callback])------------->ͨ³£ÓÃÀ´´ÓWEB·þÎñÆ÷ÉÏ»ñÈ¡¾²Ì¬µÄÊý¾ÝÎļþ
url: stringÀàÐÍ ÇëÇóHTMLÒ³ÃæµÄURLµØÖ·
data(¿ÉÑ¡): object ·¢ËÍÖÁ·þÎñÆ÷µÄkey/valueÊý¾Ý
callback(¿ÉÑ¡):function ÇëÇóÍê³Éʱ»Øµ÷º¯Êý
Àý×Ó£º
Ö÷Ò³Ãæ´úÂ룺
<style type="text/css">
* { margin:0; padding ......
¸Õµ÷ÊÔ³ÌÐòµÄʱºò±¨´íºóÈ»ºóÕҵĽâ¾ö·½·¨£¬ÏÖÔÚ·¢³öÀ´´ó¼Ò½è¼ø¡£
-----------------------
´íÎóÌáʾ£º
ÔËÐÐʱ´íÎó 800a01b6
¶ÔÏó²»Ö§³Ö´ËÊôÐÔ»ò·½·¨: Response.CharSet
---------------------------------------------------------------------
(°Ù¶Èһϣ¬»¹ÓкܶàÈËÓöµ½Í¬ÑùµÄ´íÎó)
Micros ......
Ò»¸ö¼òµ¥ajax repeater·ÖÒ³demo ¸Ä½ø°æ. ´úÂëÈçÏÂ..
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(0)">1</a>
<a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="getData(1)">2< ......
ÏÖÔÚµÄÍøÒ³ÓÐÏ൱һ²¿·ÖÊDzÉÓÃÁËAJAX¼¼Êõ,²»¹ÜÊDzÉÓÃC#ÖеÄWebClient»¹ÊÇHttpRequest¶¼µÃ²»µ½ÕýÈ·µÄ½á¹û,ÒòΪÕâЩ½Å±¾ÊÇÔÚ·þÎñÆ÷·¢ËÍÍê±Ïºó²ÅÖ´ÐеÄ!
µ«ÎÒÃÇÓÃIEä¯ÀÀÒ³ÃæÊ±ÊÇÕý³£µÄ,ËùÒÔ½â¾ö·½·¨Ö»ÓÐ1¸ö¾ÍÊDzÉÓÃWebBrowser¿Ø¼þ
µ«ÊÇʹÓÃWebbrowserÄã»á·¢ÏÖ,ÔÚDownloadCompleteʼþÖÐ,Äã¸ù±¾ÎÞ·¨ÖªµÀÒ³ÃæºÎʱ²ÅËãÊÇÕæÕýµ ......
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"& ......