zoukankan      html  css  js  c++  java
  • 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");
  • 相关阅读:
    mysql关联取附表最后一条记录,附加lareval orm实现
    lumen 常用辅助函数
    Lumen Carbon 日期及时间处理包
    $_SERVER,IP,域名常用方法
    上传Docker镜像到阿里云
    connect() failed (111: Connection refused) while connecting to upstream, cli
    linux使用常见问题
    docker实用命名
    yii 常用orm
    Hibernate多对多映射(双向关联)实例详解——真
  • 原文地址:https://www.cnblogs.com/enych/p/7921584.html
Copyright © 2011-2022 走看看