zoukankan      html  css  js  c++  java
  • asp.net Ajax

    $(function() {
                $("#Button1").click(function() {  //无参数
                    $.ajax({
                        type: "post", //访问WebService使用Post方式请求
                        contentType: "application/json", //WebService 会返回Json类型
                        url: "WebService.asmx/HelloWorld",  //调用WebService的地址和方法名称组合
                        data: "{}",     //这里是要传递的参数,格式为 data: "{paraName:paraValue}",
                        dataType: "json",
                        success: function(result) { //回调函数,result,返回值
                            $("#Label1").html(result.d);
                        }
                    });
                });
                $("#Button2").click(function() {
                    $.ajax({
                        type: "post",
                        contentType: "application/json",
                        url: "WebService.asmx/GetWish",
                        data: "{value1:'万事如意',value2:'心想事成',value3:'牛牛牛',value4:'2011'}",
                        dataType: "json",
                        success: function(result) {
                            $("#Label2").html(result.d);
                        }
                    });
                });
                $("#Button3").click(function() {
                    $.ajax({
                        type: "post",
                        contentType: "application/json",
                        url: "../MapBar/MapBarWebService.asmx/GetJD",
                        data: "{}",
                        dataType: "json",
                        success: function(result) {
                            $(result.d).each(function() {
                                $("#Label3").html(this.toString() + "," + $("#Label3").html());
                            });
                        }
                    });
                });
                $("#Button4").click(function() {   //ajax调用后台方法必须为静态方法
                    $.ajax({
                        type: "post",
                        contentType: "application/json",
                        url: "JqueryWebService.aspx/GetStr",
                        data: "{str:'jquery调用后台方法'}",
                        dataType: "json",
                        success: function(result) {
                            $("#Label4").html(result.d);
                        }
                    });
                });
            });

  • 相关阅读:
    再谈应用程序单例运行(只能开启一个进程)
    wpf 无边框窗口 最大化,缩放问题修复
    AutoClose=false的情况下自动关闭下拉框(ToolStripHost)
    C#调用其他语言(如PB)的com组件
    再写Javascript闭包
    Vue 数据双向绑定的误区
    后台数据缓存的一点心得
    C# 使用 Newtonsoft.Json 对DataTable转换中文乱码问题的解决
    第二章 Background & Borders 之 Multiple borders
    第二章 Background & Borders 之 Transparent Border
  • 原文地址:https://www.cnblogs.com/ajun/p/2364282.html
Copyright © 2011-2022 走看看