zoukankan      html  css  js  c++  java
  • 我的第一个JqueryDemo

    实例功能说明:

       当点击"获取时间"的按钮时,能够在不刷新页面的前提下获取系统当前时间. 

    1:前台页面代码:

     <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="WebApplication1.Test" %>


    <!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">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <head runat="server">
        <title></title>
        <script type="text/javascript" language="javascript">

            $(
    function () {
                $(
    "#btnGet").click(function () {
                    $.post(
    "DataGet.ashx", { "ID"1"Name""黎明" },
                                        
    function (data, state) {
                                            
    if (state == "success") {
                                                $(
    "#txtDate").val(data);
                                            }
                                        }
                                    );
                });
            });
        
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <input type="text" id="txtDate" /><input type="button" id="btnGet"  value="获取时间"/>
        </div>
        </form>
    </body>

    </html> 

     2:一般处理程序:DataGet.ashx,代码如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    namespace WebApplication1
    {
        /// <summary>
        
    /// DataGet 的摘要说明
        
    /// </summary>
        public class DataGet : IHttpHandler
        {

            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
               // context.Response.Write("Hello World");
                context.Response.Write(DateTime.Now.ToLongTimeString());
            }

            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }

    } 

     在实践中最容易出现错误的地方是:由于括号太多,而且都是使匿名方法,所以容易少了括号或多打括号.

  • 相关阅读:
    JAVA软件开发职责
    Redis主从复制配置
    VirtualBox安装Ubuntu教程
    分段锁——ConcurrentHashMap
    阻塞队列BlockingQueue用法
    阻塞队列--LinkedBlockingQueue
    MySQL百万级数据库优化方案
    获取主机的对外ip
    联通沃云开启80端口
    Nginx 正则匹配
  • 原文地址:https://www.cnblogs.com/zhangzt/p/2197819.html
Copyright © 2011-2022 走看看