zoukankan      html  css  js  c++  java
  • JQuery Ajax

    http://api.jquery.com/jquery.ajax/

    http://www.runoob.com/jquery/jquery-ref-ajax.html

    $.ajax({
                            type: 'POST',
                            url: '<%= ResolveUrl("~/api/Chile/Point/Retrieval") %>',
                            data: JSON.stringify(paras),
                            contentType: 'application/json',
                            beforeSend: function () {
                                $("#btnRetrieval").attr({ disabled: "disabled" });
                            },
                            success: function (msg) {
                                $("#btnRetrieval").removeAttr("disabled");
                                if (msg.IsSuccess) {
                                    //$("#modalConfirmated").modal();
                                    window.location.href = "<%= ResolveUrl(CMSContext.GetUrl(OkUrl)) %>";
                                } else {
                                    $("#modelFailedText").html(msg.Message);
                                    $("#UpdateModalFailed").modal({ backdrop: 'static' });
                                }
                            }
                        });
    • type (default: 'GET')
      Type: String
      An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0.
    • url (default: The current page)
      Type: String
      A string containing the URL to which the request is sent.
    • data
      Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).
    • contentType (default: 'application/x-www-form-urlencoded; charset=UTF-8')
      Type: Boolean or String
      When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). As of jQuery 1.6 you can pass false to tell jQuery to not set any content type header. Note: The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. Note: For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server.
    • beforeSend
      Type: Function( jqXHR jqXHR, PlainObject settings )
      A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.
    • success
      Type: Function( Anything data, String textStatus, jqXHR jqXHR )
      A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter or the dataFilter callback function, if specified; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.
  • 相关阅读:
    OpenCV进阶之路:神经网络识别车牌字符
    System.ComponentModel.DataAnnotations.Schema.TableAttribute 同时存在于EntityFramework.dll和System.ComponentModel.DataAnnotations.dll中
    windows server 禁用智能卡服务的步骤
    yum 安装时错误 Errno 14 Couldn't resolve host 解决办法
    解决 CentOS7 安装完成后ifconfig命令不能用
    C#下RSA算法的实现(适用于支付宝和易宝支付)
    centos下问题:connect:network is unreachable
    maven 跳过单元测试
    Docker
    Jenkins和Docker
  • 原文地址:https://www.cnblogs.com/chucklu/p/8064058.html
Copyright © 2011-2022 走看看