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
Ïà¹ØÎĵµ£º
ÇëÇó·½Ê½£¬·ÖΪGETÓëPOST£º
GET
×îΪ³£¼ûµÄHTTPÇëÇ󣬯ÕͨÉÏÍøä¯ÀÀÒ³Ãæ¾ÍÊÇGET¡£GET·½Ê½µÄ²ÎÊýÇëÇóÖ±½Ó¸úÔÚURLºó£¬ÒÔÎʺſªÊ¼¡££¨JSÖÐÓÃwindow.location.search»ñµÃ£©¡£²ÎÊý¿ÉÒÔÓÃencodeURIComponent½øÐбàÂ룬ʹÓ÷½Ê½:
var EnParam = encodeURIComponent(param);
URLÖ»Ö§³Ö´óÔ¼2KµÄ³¤¶È£¬¼´2 ......
ajaxÈ«³ÆAsynchronous JavaScript and Xml ,Òì²½´«Êä¡£
Òì²½´«ÊäÊÇÃæÏò×Ö·ûµÄ´«Ê䣬ËüµÄµ¥Î»ÊÇ×Ö·û£»¶øÍ¬²½´«ÊäÊÇÃæÏò±ÈÌØµÄ´«Ê䣬ËüµÄµ¥Î»ÊÇÖ¡£¬Ëü´«ÊäµÄʱºòÒªÇó½ÓÊÜ·½ºÍ·¢ËÍ·¢µÄʼÖÕ±£³ÖÒ»Öµġ£
Òì²½´«ÊäÊǽ«±ÈÌØ·Ö³ÉС×éÀ´½øÐд«Êä¡£Ò»°ãÿ¸öС×éµÄÒ»¸ö8λ×Ö·û£¬ÔÚÿ¸öС×éµÄ ......
ʲôÊÇ AJAX?
¡¡¡¡AJAX (Òì²½ JavaScript ºÍ XML) ÊǸöвúÉúµÄÊõÓï,רΪÃèÊöJavaScriptµÄÁ½ÏîÇ¿´óÐÔÄÜ.ÕâÁ½ÏîÐÔÄÜÔÚ¶àÄêÀ´Ò»Ö±±»ÍøÂ翪·¢ÕßËùºöÂÔ,Ö±µ½×î½üGmail, Google suggestºÍgoogle MapsµÄºá¿Õ³öÊÀ²ÅʹÈËÃÇ¿ªÊ¼Òâʶµ½ÆäÖØÒªÐÔ.
¡¡¡¡ÕâÁ½Ïî±»ºöÊÓµÄÐÔÄÜÊÇ:
¡¡¡¡ÎÞÐèÖØÐÂ×°ÔØÕû¸öÒ³Ãæ±ãÄÜÏò·þÎñÆ÷·¢ËÍÇëÇó.
¡¡¡ ......
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 ......
jQueryÊÇÒ»¸ö¿ÉÒÔ¼ò»¯ JavaScript?ÒÔ¼°AJAX£¨Asynchronous JavaScript
+XML£¬Òì²½JavascriptºÍXML£©±à³ÌµÄJavascript¿â¡£²»Í¬ÓÚÆäËûµÄJavascript¿â£¬jQueryÓÐËû×Ô¼ºµÄÕÜѧ£¬Ê¹Äã¿É
ÒԺܼòµ¥µÄ±àд´úÂë¡£ÕâÆªÎÄÕÂ¾Í»á´øÁìÄã¼ûʶһÏÂjQueryµÄÕÜѧ£¬Ì½ÌÖÒ»ÏÂËûµÄÌØÐÔÒÔ¼°¹¦ÄÜ£¬²¢ÇÒ»á×öһЩajaxµÄʾÀý£¬ÒÔ¼°ÈçºÎʹÓÃplug-
......