Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

jQuery AJAX»Øµ÷º¯ÊýthisÖ¸ÏòÎÊÌâ

Á˽âJavaScriptµÄÈ˶¼ÖªµÀJavaScriptµÄthis²»×ÜÊÇÖ¸Ïòµ±Ç°¶ÔÏ󣬺¯Êý»òÀàÖеÄthisÖ¸ÏòÓëµ÷ÓÃÕâ¸öº¯ÊýµÄ¶ÔÏóÒÔ¼°ÉÏÏÂÎÄ»·¾³ÊÇϢϢÏà¹ØµÄ¡£ÈçÔÚÈ«¾Ö×÷ÓÃÓòµ÷ÓÃÒ»¸öº¬thisµÄ¶ÔÏ󣬴Ëʱµ±Ç°¶ÔÏóµÄthisÖ¸ÏòµÄÊÇwindow¡£ÎªÁËÈÃthisµÄÖ¸Ïò·ûºÏ×Ô¼ºµÄÒâÔ¸£¬JavaScriptÌṩÁËÁ½¸ö·½·¨ÓÃÒԸıäthisµÄÖ¸Ïò£¬ËüÃÇÊÇcallºÍapply£¬µ±È»Ò²ÓÐÀûÓñհüÀ´ÊµÏֵķ½·¨¡£±¾ÎÄͨ¹ýÒ»¸öÀý×ÓÀ´ËµÃ÷ÕâЩÎÊÌâ¡£
ÏÈ¿´Ò»¶ÎÑÝʾ´úÂ룬Õâ´úÂëÖ»¹©ÑÝʾÓã¬Ã»ÓÐʵ¼ÊÒâÒå¡£
//Ò»¸öûÓÐʵ¼ÊÒâÒåµÄsocketÁ¬½Ó¶ÔÏó
var socket = 
{
    connect: function(host, port)
    {
        alert('Connecting socket server,host:' + host + ',port:' + port);
    }
};
//Ò»¸ö¼´Ê±Í¨Ñ¶À࣬ÆäÖÐconnect·½·¨»¹½«×÷ΪAJAX»Øµ÷º¯Êý±»µ÷ÓÃ
function classIm()
{
    this.host = '192.168.1.28';
    this.port = '8080';
    this.connect = function(data)
    {
        socket.connect(this.host, this.port);
    };
}
//ʵÀý»¯¼´Ê±Í¨Ñ¶Àà
var IM = new classIm();
//AJAXÇëÇó£¬ÕâÀï¼ÙÉèÒª´ò¿ªsocketÁ¬½ÓÊ×ÏÈҪͨ¹ýWEBµÃÖªÓû§WEBµÇ¼³É¹¦
$.get('CheckWebLogin.aspx', IM.connect);
ÔËÐÐÉÏÃæµÄÀý×Ó£¬Ä㽫¿´µ½µ¯³öµÄhostÓëport¶¼ÊÇundefined£¬ÄÇÊÇÒòΪ»Øµ÷º¯ÊýµÄthis²»ÊÇÖ¸ÏòIM¶ÔÏ󣬶øÊÇjQueryµÄAJAXÅäÖöÔÏóajaxSettings¡£ÔÚjQueryÄÚ²¿ÊÇÓÃs.success´úÌæ´«ÈëµÄ»Øµ÷º¯ÊýÈ¥Ö´Ðеģ¬¶øsuccessµÄµ÷ÓöÔÏó¾ÍÊÇs£¬¼´ÏÂÃæajaxSettings¶ÔÏóµÄËõд¡£
ajaxSettings: 
{
    url: location.href,
    global: true,
    type: "GET",
    contentType: "application/x-www-form-urlencoded",
    processData: true,
    async: true
}
ΪÁËÖ¤Ã÷ÕâÒ»µã£¬Äã¿ÉÒÔÕâÑùÐ޸ĴúÂë²âÊÔһϣ¬Ä㽫¿´µ½ÊÇurl¡¢glo


Ïà¹ØÎĵµ£º

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"& ......

Ajax ¸´ÔÓÊý¾ÝÀàÐÍʹÓûù´¡

¸´ÔÓÊý¾ÝÀàÐÍʹÓûù´¡
•¹«ÓÐÊôÐÔ»ò¹«ÓÐField»á±»ÊͷźͽÓÊÜ
•ÈÝÆ÷¶ÔÏó
–ʵÏÖIList½Ó¿ÚµÄ¶ÔÏó
–ʵÏÖIDictionary½Ó¿ÚµÄ¶ÔÏó
•Key±ØÐëÊÇString
WebService2.cs Code£º
using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Service ......

AJAXʵ¼ùDWRƪ

DWR(Direct Web Remoting)ÊÇÒ»¸öWEBÔ¶³Ìµ÷Óÿò¼Ü.ÀûÓÃÕâ¸ö¿ò¼Ü¿ÉÒÔÈÃAJAX¿ª·¢±äµÃºÜ¼òµ¥.ÀûÓÃDWR¿ÉÒÔÔÚ¿Í»§¶ËÀûÓÃJavaScriptÖ±½Óµ÷Ó÷þÎñ¶ËµÄJava·½·¨²¢·µ»ØÖµ¸øJavaScript¾ÍºÃÏñÖ±½Ó±¾µØ¿Í»§¶Ëµ÷ÓÃÒ»Ñù(DWR¸ù¾ÝJavaÀàÀ´¶¯Ì¬Éú³ÉJavaScrip´úÂë).ËüµÄ×îа汾DWR0.6Ìí¼ÓÐí¶àÌØÐÔÈç:Ö§³ÖDom TreesµÄ×Ô¶¯ÅäÖÃ,Ö§³ÖSpring(JavaS ......

ajax.dll .netÖмòµ¥Ê¹ÓÃajax

ajax.dllÒѾ­ÊǺÜÀϵĶ«Î÷ÁË£¬µ«ÊǽñÌìÎÒ²ÅÓõ½Ëü£¬ÏÖÔÚ°ÑËüµÄʹÓ÷½·¨¼Ç¼ÏÂÀ´¡£
1.ÔÚweb.configÖÐÅäÖÃajaxµÄ´¦Àí³ÌÐò¡£
<httpHandlers>
     <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
<httpHandlers>
2. ×¢²á´¦Àí³ÌÐòÀ࣬ajaxTestÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ