jquery ajaxÈ«½âÎö
jQuery Ajax È«½âÎö
±¾ÎĶÌÖ·£ºhttp://s8.hk/0itq
±¾ÎĵØÖ·: jQuery Ajax È«½âÎö
±¾ÎÄ×÷ÕߣºQLeelulu
תÔØÇë±êÃ÷³ö´¦£¡
jQueryȷʵÊÇÒ»¸öͦºÃµÄÇáÁ¿¼¶µÄJS¿ò¼Ü£¬ÄÜ°ïÖúÎÒÃÇ¿ìËٵĿª·¢JSÓ¦Ó㬲¢ÔÚÒ»¶¨³Ì¶ÈÉϸıäÁËÎÒÃÇдJavaScript´úÂëµÄÏ°¹ß¡£
·Ï»°ÉÙ˵£¬Ö±½Ó½øÈëÕýÌ⣬ÎÒÃÇÏÈÀ´¿´Ò»Ð©¼òµ¥µÄ·½·¨£¬ÕâЩ·½·¨¶¼ÊǶÔjQuery.ajax()½øÐзâ×°ÒÔ·½±ãÎÒÃÇʹÓõķ½·¨£¬µ±È»£¬Èç¹ûÒª´¦Àí¸´ÔÓµÄÂß¼£¬»¹ÊÇÐèÒªÓõ½jQuery.ajax()µÄ(Õâ¸öºóÃæ»á˵µ½).
1. load( url, [data], [callback] ) £ºÔØÈëÔ¶³Ì HTML Îļþ´úÂë²¢²åÈëÖÁ DOM ÖС£
url (String) : ÇëÇóµÄHTMLÒ³µÄURLµØÖ·¡£
data (Map) : (¿ÉÑ¡²ÎÊý) ·¢ËÍÖÁ·þÎñÆ÷µÄ key/value Êý¾Ý¡£
callback (Callback) : (¿ÉÑ¡²ÎÊý) ÇëÇóÍê³Éʱ(²»ÐèÒªÊÇsuccessµÄ)µÄ»Øµ÷º¯Êý¡£
Õâ¸ö·½·¨Ä¬ÈÏʹÓà GET ·½Ê½À´´«µÝµÄ£¬Èç¹û[data]²ÎÊýÓд«µÝÊý¾Ý½øÈ¥£¬¾Í»á×Ô¶¯×ª»»ÎªPOST·½Ê½µÄ¡£jQuery 1.2 ÖУ¬¿ÉÒÔÖ¸¶¨Ñ¡Ôñ·û£¬À´É¸Ñ¡ÔØÈëµÄ HTML Îĵµ£¬DOM Öн«½ö²åÈëɸѡ³öµÄ HTML ´úÂë¡£Óï·¨ÐÎÈç "url #some > selector"¡£
Õâ¸ö·½·¨¿ÉÒԺܷ½±ãµÄ¶¯Ì¬¼ÓÔØһЩHTMLÎļþ£¬ÀýÈç±íµ¥¡£
ʾÀý´úÂ룺
$(".ajax.load").load("http://www.cnblogs.com/QLeelulu/archive/2008/03/30/1130270.html .post",
function (responseText, textStatus, XMLHttpRequest){
this;//ÔÚÕâÀïthisÖ¸ÏòµÄÊǵ±Ç°µÄDOM¶ÔÏ󣬼´$(".ajax.load")[0]
//alert(responseText);//ÇëÇ󷵻صÄÄÚÈÝ
//alert(textStatus);//ÇëÇó״̬£ºsuccess£¬error
//alert(XMLHttpRequest);//XMLHttpRequest¶ÔÏó
});
ÕâÀォÏÔʾ½á¹û¡£
×¢£º²»ÖªµÀΪʲôURLд¾ø¶Ô·¾¶ÔÚFFÏ»á³ö´í£¬ÖªµÀµÄÂé·³¸æËßÏ¡£ÏÂÃæµÄget()ºÍpost()ʾÀýʹÓõÄÊǾø¶Ô·¾¶£¬ËùÒÔÔÚFFÏÂÄ㽫»á³ö´í²¢²»»á¿´µ½·µ»Ø½á¹û¡£»¹ÓÐget()ºÍpost()ʾÀý¶¼ÊÇ¿çÓòµ÷Óõģ¬·¢ÏÖ´«ÉÏÀ´ºóû°ì·¨»ñÈ¡½á¹û£¬ËùÒÔ°ÑÔËÐа´Å¥È¥µôÁË¡£
2. jQuery.get( url, [data], [callback] )£ºÊ¹ÓÃGET·½Ê½À´½øÐÐÒì²½ÇëÇó
²ÎÊý£º
url (String) : ·¢ËÍÇëÇóµÄURLµØÖ·.
data (Map) : (¿ÉÑ¡) Òª·¢Ë͸ø·þÎñÆ÷µÄÊý¾Ý£¬ÒÔ Key/value µÄ¼üÖµ¶ÔÐÎʽ±íʾ£¬»á×öΪQueryString¸½¼Óµ½ÇëÇóURLÖС£
callback (Function) : (¿ÉÑ¡) ÔØÈë³É¹¦Ê±»Øµ÷º¯Êý(Ö»Óе±ResponseµÄ·µ»Ø״̬ÊÇsuccess²ÅÊǵ÷Óø÷½·¨)¡£
ÕâÊÇÒ»¸ö¼òµ¥µÄ GET ÇëÇó¹¦ÄÜÒÔÈ¡´ú¸´ÔÓ $.ajax ¡£ÇëÇó³É¹¦Ê±¿Éµ÷Óûص÷º¯Êý¡£Èç¹ûÐèÒªÔÚ³ö´íʱִÐк¯Ê
Ïà¹ØÎĵµ£º
ÄÚÈÝÒ³£º
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ScriptManagerProxyDemo.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javas ......
ºÜ¶àÅóÓÑÎÊÎÒÈçºÎʵÏÖÎÞË¢ÐÂÉÏ´«Í¼Æ¬,ÕâÀïСºÚ¸ø´ó¼ÒÕÒÁËһƪ¹ØÓÚÎÞË¢ÐÂʵÏÖͼƬÉÏ´«µÄÎÄÕÂ,Ï£Íû¶Ô´ó¼ÒÓаïÖú.
±¾ÎÄ¿Í·þ¶ËʹÓõÄÊÇajax.netÒì²½ÉÏ´«Îļþ
1.ÔÚ
protected void Page_Load(object sender, EventArgs e)
{
Ajax.Utilit ......
Ajax´«²ÎÂÒÂë AjaxÖÐÎÄÂÒÂë ½â¾ö
ÔÚAjax url´«²Îʱ³öÏÖÖÐÎÄÂÒÂëµÄÇé¿ö,½â¾ö·½·¨:
Àý1: xmlHttp.open("GET","Engine.aspx?Action=getmainsort&Type= ......
ÓÃstruts2+jquery+json+hibernate+ajax×öÁËÒ»¸öµÇ½µÄdemo¡£
1.jspÒ³Ãæ
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/x ......
Ê×ÏȽéÉÜÒ»ÏÂJavaScript£º
JavaScirpt ÊÇÒ»ÖÖ¿ÉÒÔÓÃÀ´¸øÍøÒ³Ôö¼Ó½»»¥ÐԵıà³ÌÓïÑÔ¡£³£³£»á¿´µ½JavaScript±»³ÆΪ“½Å±¾ÓïÑÔ”£¨Scripting language£©£¬Õⰵʾ×ÅËü¸üÊʺϱàд½Å±¾¶ø²»ÊdzÌÐò¡£Õâʵ¼ÊÉϲ¢Ã»Óиú²»ÉϵIJîÒì¡£JavaScript½Å±¾Ò²ÊÇÒ»ÖÖ³ÌÐò£¬Ëü°üº¬ÔÚHTMLÒ³ÃæÉÏ£¬ÒòΪ½Å±¾Îı¾°üΧÔÚ<Script>±êÇ©Ö ......