zoukankan      html  css  js  c++  java
  • 放放风

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Services;
    using System.Web.Script.Services;

    namespace ajax
    {
    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    Response.Write("xx");
    }


    // 需要被Ajax请求的后台方法
    [WebMethod]
    // [ScriptMethod(UseHttpGet = true)] // 如果要使用POST请求,去掉这个标记
    public static string RequestedMethod(string msg)
    {
    return msg;
    }
    }
    }

    <!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>
    <title></title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    </head>
    <body>
    <script type="text/javascript">
    // $(document).ready(function () {
    // $("#btn2").click(function () {
    // $.ajax({
    // type: "POST",
    // contentType: "application/json",
    // url: "WebService1.asmx/GetWish",
    // data: "{value1:'心想事成',value2:'万事如意',value3:'牛牛牛',value4:2009}",
    // dataType: 'json',
    // success: function (result) {
    // $('#dictionary').append(result.d);
    // }
    // });
    // });
    // });

    $(document).ready(
    function () {
    $("#btn2").click(
    function () {
    $.ajax({
    type: "Post",
    url: "Default.aspx/RequestedMethod",
    data: "{'msg':'hello'}",
    contentType: "application/json;charset=utf-8", // 这句可不要忘了。
    dataType: "json",
    success: function (res) {
    $("#dataShow").text("success:" + res.d); // 注意有个d,至于为什么通过chrome看响应吧,O(∩_∩)O。
    },
    error: function (xmlReq, err, c) {
    $("#dataShow").text("error:" + err);
    }
    });
    }

    );


    }

    );


    </script>
    <div class="button" id="btn2">
    传入参数</div>
    <div id="dataShow"></div>
    </body>
    </html>

  • 相关阅读:
    Fast Member
    C++箴言:理解typename的两个含义
    网上资源工具
    WeakReference
    MonoGame教程
    The RAII Programming Idiom
    OpenGL Common Mistakes
    Finalize()、Dispose()、SafeHandle、GC
    Interop with Native Libraries
    C++计算几何库
  • 原文地址:https://www.cnblogs.com/terryzh/p/4572250.html
Copyright © 2011-2022 走看看