zoukankan      html  css  js  c++  java
  • AjaxPro.2 与 Jquery 的 Ajax 的混合使用

    AjaxPro.2 与 Jquery 的 Ajax 的混合使用 效果相当好,可以随心所欲

    //前台 代码 
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="AjaxPro.aspx.cs" Inherits="AjaxPro_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">
    <head runat="server">
        <title></title>
        <script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            function ajaxTest() {
                AjaxPro_Test.AjaxProcTest(ajaxTestCallBack);
            }
            function ajaxTestCallBack() {
                alert('AjaxProcTest');
            }
    
            function JqueryAjaxTest() {
                $.ajax({
                    type: "GET",
                    url: "/ajax.asmx/AjaxProcTest",
                    contentType: "application/xml",
                    dataType: 'html',
                    error: function() { alert('error'); },
                    success: function(data) {
                        alert(data);
                    }
                });
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <input type="button" value="AjaxPro 无参调用" onclick="ajaxTest()" />
            <input type="button" value="JqueryAjax调用" onclick="JqueryAjaxTest()" />
        </form>
    </body>
    </html>
    
    //后台 代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class AjaxPro_Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //注册
            AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxPro_Test));
        }
    
        [AjaxPro.AjaxMethod]
        public void AjaxProcTest()
        {
            // "AjaxPro 无参调用";
        }
    }
    
    //ajax.asmx 的代码
        [WebMethod]
        public string AjaxProcTest()
        {
            return "AjaxProcTest";
        }

    这种使用可以兼容ie6,7,8, firFox,Chorme

  • 相关阅读:
    Codeforces Round #622 (Div. 2)
    Knapsack Cryptosystem 牛客团队赛
    HDU 2586(LCA欧拉序和st表)
    P3865 【模板】ST表
    P2023 [AHOI2009]维护序列 区间加乘模板
    P1558 色板游戏 线段树(区间修改,区间查询)
    Codeforces Round #621 (Div. 1 + Div. 2) D
    Codeforces Round #620 (Div. 2) E
    Educational Codeforces Round 82 (Rated for Div. 2)
    洛谷P1638 逛画展
  • 原文地址:https://www.cnblogs.com/challengesoflife/p/2821391.html
Copyright © 2011-2022 走看看