¼òµ¥Ó¦¸ÃajaxÎÞˢлñÈ¡Êý¾Ý
Ajax¿ÉÒÔʵÏÖÍøÒ³µÄ¾Ö²¿Ë¢ÐÂ,ÊÇͨ¹ýJS»ñÈ¡Êý¾Ý,ÔÙ°ÑÊý¾ÝÌí¼Óµ½ÍøÒ³ÖÐ,È»¶øÓÉÓÚä¯ÀÀÆ÷µÄ²»Í¬,³õѧÕߺÜÄÑ×öµ½¼æÈÝÎÊÌâ.
ÕâÀïÎÒÏò´ó¼Ò½éÉÜÒ»Öֺõķ½·¨.ͨ¹ýJQuery²å¼þ.JQuery.jsÎļþ¿ÉÒÔÔÚ¹ÙÍøÉÏÏÂÔØ,»òÕßgoogleÒ²ÐÐ.
Ê×ÏÈÄãÒªÔÚÍøÒ³ÒýÈëJSÎļþ
<script src="../javascript/jquery.js" type="text/javascript"></script>
È»ºóÔÚʼþÖÐ(click)»ñÈ¡Êý¾Ý
jQuery("#chtnavi").html("ÕýÔÚ»ñÈ¡Êý¾Ý...");
jQuery.ajax({
url : "ajax.aspx",//ÕâÊǵØÖ·
type : "post",//ÕâÊǻط¢·½Ê½
data : "id="+value,//ÕâÊDzÎÊý,Èç¹ûûÓÐÔòΪ¿Õ
dataType : "html",
complete :
function (http,status)
{
if(status=="success")
{
jQuery("#chtnavi").html(http.responseText);
}
}
});
±ÈÈç˵ÄãÔÚajax.csÖÐÊä³öResponse.Write("this is test");ÄÇôµÃµ½µÄ¾ÍÊÇthis is test.
µ±È»,ΪÁË´«ÊäÊý¾ÝµÄ×îС»¯,JQuery»¹ÓÐÒ»¸öJSon·½Ê½,ÈçÏÂ
var url='../ajax.aspx;id='+escape(s);
$.getJSON(url, function(data)
{
if(data.ok==1)
{//do something}
else if(data.ok==2)
{//do something}
else
&
Ïà¹ØÎĵµ£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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=" ......
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 ......
ʵʱÊý¾ÝÑéÖ¤ÊÇAJAX¼¼ÊõµÄÒ»´óÓÅÊÆÖ®Ò»¡£Í¨¹ýÓ¦Óô˼¼Êõ£¬strutsÑéÖ¤¿ò¼Ü½«ÔöÇ¿struts MVC£¬²¢Ê¹WebÓ¦ÓóÌÐò¸ü½Ó½üÓÚ×ÀÃæÓ¦ÓóÌÐò¡£
´ËÑéÖ¤¿ò¼ÜÓÃÓÚÑéÖ¤×ֶΡ£ÓÐÐí¶àÔÚWebÓ¦ÓóÌÐòÉϽøÐÐÑéÖ¤µÄ·½·¨¡£ÕâЩ·½·¨¿É·ÖΪÁ½Àࣺ·þÎñÆ÷¶Ë·½·¨ºÍ¿Í»§¶Ë·½·¨¡£StrutsÑéÖ¤¿ò¼ÜÊÇÃæÏò»ùÓÚJavaµÄWebÓ¦Óû·¾³µÄ×î¼Ñ¿ò¼ÜÖ®Ò»¡£ËüÄܹ»ÅäÖÃÓ ......
ÍêÈ«ÊÊÓÃASP.NETµÄÈÏÖ¤»úÖÆ
–¿ÉÒÔʹÓÃFormsAuthentication
•WebService·½·¨¿ÉÒÔ²Ù×÷Cookie
–Impersonation
–PrincipalPermission
WebService7.cs Code
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
usi ......
jQuery Ajax È«½âÎö
±¾ÎĶÌÖ·£ºhttp://s8.hk/0itq
<!--
.ajax div{
border: solid 1px red;
}
-->
// <![CDATA[
$(function(){
$("#btnajax").click(function(){
$.ajax({
type: "get",
url: "/rss",
beforeSend: function(XMLHttpRequ ......