zoukankan      html  css  js  c++  java
  • MVC的Ajax异步请求

      @using (Ajax.BeginForm("GetTime","order",new AjaxOptions()
                {
                    Confirm="你确认这么做吗?",
                    HttpMethod="post",
                    OnSuccess = "afterajax",
                    UpdateTargetId="result",
                    InsertionMode=InsertionMode.Replace,
                    LoadingElementId = "loading",
                }))
            {
                
                <input type="text" name="txtname" />
                <input type="submit" name="获取时间"  />           
            }
            <div id="loading">
                <img src="~/Content/Images/loading.gif" />
            </div>
            <div id="result">
    
            </div>   


      Html部分代码

    <script src="~/Scripts/jquery-1.8.2.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <script type="text/javascript">
    $(function () {
    $("#loading").css("display", "none");
    $("#btnGetTime").click(function () { 
    $.ajax({
    url: "/order/GetTime",
    data: {},
    type: "post",
    success: function (data) {
    alert(data);
    }
    
    });
    $.get("/order/GetTime", {}, function (data) {
    alert(data);
    });
    }
    )
    });
    function afterajax(data) {
    alert("ff");
    
    }
    function aff() {
    $("#loading").css("display", "none");
    }
    
    
    </script>
    

      

  • 相关阅读:
    Python-单例模式
    Django 内置模板标签和过滤器
    Python Built-in Function 学习笔记
    Django 中间件
    Django Form
    Ajax
    Django中cookie和session
    Django中的QuerySet
    Django模型和ORM
    wordpress添加子主题
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/3705185.html
Copyright © 2011-2022 走看看