jquery+ajax+asp.net实现Ajax操作

文章简介:关于jquery+ajax+asp.net实现Ajax操作的简介

jquery,ajax,asp.net

是jquery+ajax+ashx的   现在这个是Handler.ashx:

========================================================================

<%@ WebHandler Language="C#" class="Handler" %>

using System;

using System.Web;

...jquery+ajax+asp.net实现Ajax操作

 

是jquery+ajax+ashx的   现在这个是Handler.ashx:

========================================================================

<%@ WebHandler Language="C#" class="Handler" %>

using System;

using System.Web;

public class Handler : IHttpHandler {

    

    public void ProcessRequest (HttpContext context) {

        char method = Convert.ToChar(context.Request.Params["m"]);

        context.Response.ContentType = "text/plain";

        switch (method)

        {

            case 'a':

                context.Response.Write("Hello World<br/>This is a sample");

                return;

            case 'b':

                context.Response.Write("Hello World<br/>This is b sample");

                return;                

        }

        context.Response.Flush();  

    }

}

================================================================

jquery调用代码:

=================================================================

$(document).ready(function(){

            $("#test2").click(function(){

                $.ajax({

                    type : "post",

                    url : "Handler.ashx",

                    data : {m:'a'},

                    success : function(result){

                        $("#testText").append(result + "<br/>");

                    }

                });

            });

        });

        $(document).ready(function(){

            $("#test3").click(function(){

                $.ajax({

                    type : "post",

文章简介:关于jquery+ajax+asp.net实现Ajax操作的简介

jquery,ajax,asp.net

是jquery+ajax+ashx的   现在这个是Handler.ashx:

========================================================================

<%@ WebHandler Language="C#" class="Handler" %>

using System;

using System.Web;

...jquery+ajax+asp.net实现Ajax操作

 

是jquery+ajax+ashx的   现在这个是Handler.ashx:

========================================================================

<%@ WebHandler Language="C#" class="Handler" %>

using System;

using System.Web;

public class Handler : IHttpHandler {

    

    public void ProcessRequest (HttpContext context) {

        char method = Convert.ToChar(context.Request.Params["m"]);

        context.Response.ContentType = "text/plain";

        switch (method)

        {

            case 'a':

                context.Response.Write("Hello World<br/>This is a sample");

                return;

            case 'b':

                context.Response.Write("Hello World<br/>This is b sample");

                return;                

        }

        context.Response.Flush();  

    }

}

================================================================

jquery调用代码:

=================================================================

$(document).ready(function(){

            $("#test2").click(function(){

                $.ajax({

                    type : "post",

                    url : "Handler.ashx",

                    data : {m:'a'},

                    success : function(result){

                        $("#testText").append(result + "<br/>");

                    }

                });

            });

        });

        $(document).ready(function(){

            $("#test3").click(function(){

                $.ajax({

                    type : "post",

                    url : "Handler.ashx",

                    data : {m:'b'},

                    success : function(result){

                        $("#testText").append(result + "<br/>");

                    }

                });

            });

        });

                    url : "Handler.ashx",

                    data : {m:'b'},

                    success : function(result){

                        $("#testText").append(result + "<br/>");

                    }

                });

            });

        });

posted @ 2012-07-12 14:35  bingzer  阅读(174)  评论(0)    收藏  举报