>  기사  >  백엔드 개발  >  Asp.net Jquery Ajax 예

Asp.net Jquery Ajax 예

高洛峰
高洛峰원래의
2016-12-16 16:30:051154검색

jquery 라이브러리 최신 버전 다운로드: jquery-1.4.2min.js

jquery 1.3.2mini 버전: jquery-1.3.2min.js

중국어 수동 다운로드 주소(정말 멋지네요. 버전) :jquery12api

프런트 엔드 코드:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajax.aspx.cs" Inherits="ajax" %>  
<!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>Jquery Ajax实例</title>  
    <mce:script type="text/<a href="http://lib.csdn.net/base/javascript" class=&#39;replace_word&#39; title="JavaScript知识库" target=&#39;_blank&#39; style=&#39;color:#df3434; font-weight:bold;&#39;>JavaScript</a>" src="script/jquery-142min.js" mce_src="script/jquery-142min.js"></mce:script>  
    <mce:script type="text/javascript"><!--  
$(function() {  
    $("#dbtn").click(function(){  
        $.ajax({  
               type: "POST",  
               //dataType:"Text",  
               url:"Handler.ashx",  
               data:{name:"admin",pass:"admin"},  
               beforeSend:function(){  
               $("#ds").html("loading");  
               },  
               success: function(msg){  
                $("#ds").html("<p>"+msg+"</p>");  
               }  
        });       
          
    });  
});  
// --></mce:script>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
    <div id="ds"><p>我是AJAX原来的文字!</p></div>  
    <input type="button" value="提交AJAX<a href="http://lib.csdn.net/base/softwaretest" class=&#39;replace_word&#39; title="软件测试知识库" target=&#39;_blank&#39; style=&#39;color:#df3434; font-weight:bold;&#39;>测试</a>" id="dbtn" name="dbtn" />  
    </div>  
    </form>  
</body>  
</html>

Handler.ashx:

<%@ WebHandler Language="C#" Class="Handler" %>  
  
using System;  
using System.Web;  
using System.Data.SqlClient;  
  
public class Handler : IHttpHandler {  
      
    public void ProcessRequest (HttpContext context) {  
        context.Response.ContentType = "text/plain";  
          
        //context.Response.Write("Hello World");  
        if (context.Request["name"].ToString() == "admin" && context.Request["pass"].ToString() == "admin")  
        {  
            context.Response.Write("Y");  
        }  
        else  
        {  
            context.Response.Write("N");  
        }  
    }  
    public bool IsReusable  
    {  
        get  
        {  
            return false;  
        }  
    }  
      
}


더 보기 Asp.net Jquery Ajax 예제 관련 기사는 PHP 중국어 웹사이트를 참고하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.