• jquery ajax


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="index1.aspx.cs" Inherits="index1" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>从另一个页面加载数据到当前页面</title>
        <script src="js/jquery-3.2.1.min.js"></script>
        <script type="text/javascript">
            $(function () {
                $("#btn").click(function () {
                    $("#box").load("test.ashx"); //load()方法法
                    //将test.ashx页面的数据加载到id 为box的元素中,如果只需要加载test.ashx页面某个元素的内容,例如加载<p>标记的内容,则可写为:
                    //$("#box").load("test.ashx p").
                });
            })
        </script>
        <script type="text/javascript">
            $(function () {
                $("#btnLogin").click(function () {
                    $("#box2").load("test.ashx", { "txtName": " admin", "txtPwd": "pwd" }); //load() 方法
    
                });
    
            })
        </script>
        <script type="text/javascript">
            $(function () {
                $("#Getbtn").click(function () { //data(发送的key/value 或json风格的字符串作为数据格式)
                    $.get("test.ashx", { "txtName": " admin", "txtPwd": "pwd" }, function (data) {
                        if (data == "ok") {
                            alert("main.aspx");
                        } else {
                            alert(data);
                        }
                    });
                });
            })
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div id="box">
                <input type="button" id="btn" value="加载数据" />
            </div>
            <div id="box2">
                <input type="button" id="btnLogin" value="登录" />
            </div>
            <div id="box3">
                <input type="button" id="Getbtn" value="GET" />
            </div>
        </form>
    </body>
    </html>
    一般处理程序 
    context.Response.ContentType = "text/plain"; string ss = context.Request["txtName"]; context.Response.Write(ss); context.Response.Write("Hello World");
  • 相关阅读:
    Using Apache Maven
    Getting Started(Google Cloud Storage Client Library)
    【iOS】PLA 3.3.12
    【Android】System.exit(0) 退出程序
    【iOS】Ineligible Devices || “无法下载应用程序”
    【iOS】No suitable application records found
    【Android】Failed to convert @drawable/picture into a drawable
    【SVN】eclipse 安装 SVN 插件
    【SVN】SVN Working copy is too old
    【Android】Android sdk content loader 0%
  • 原文地址:https://www.cnblogs.com/enych/p/7921584.html
Copyright © 2020-2023  润新知