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");
  • 相关阅读:
    java 接口返回格式
    Request must contain an kbn-xsrf header 报错
    java 类型转换
    layui中使用ajax请求后端
    string boot中get、post 接口
    mysql window 启动
    自动化--APP UI自动化--Airtest 实用命令汇总
    自动化--APP UI自动化--Airtest poco定位
    自动化--APP UI自动化--Airtest点击悬浮
    最近工作
  • 原文地址:https://www.cnblogs.com/enych/p/7921584.html
Copyright © 2011-2022 走看看