zoukankan      html  css  js  c++  java
  • jquery 关于ajax的操作

    jQuery.ajax( url [, settings] )

    urlA string containing the URL to which the request is sent.

    settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) below for a complete list of all settings.

    async Boolean Default: true
     

    type

    类型:String

    默认值: "GET")。请求方式 ("POST" 或 "GET"), 默认为 "GET"。注意:其它 HTTP 请求方法,如 PUT 和 DELETE 也可以使用,但仅部分浏览器支持。

    dataObject, String

    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)。

    dataTypeString
    Default: Intelligent Guess (xml, json, script, or html)
     
    success

    类型:Function

    请求成功后的回调函数。

    参数:由服务器返回,并根据 dataType 参数进行处理后的数据;描述状态的字符串。

    这是一个 Ajax 事件。

    参看:http://api.jquery.com/jQuery.ajax/

    The jqXHR Object

    The jQuery XMLHttpRequest (jqXHR) object returned by $.ajax() as of jQuery 1.5 is a superset of the browser's native XMLHttpRequest object. For example, it containsresponseText and responseXML properties, as well as a getResponseHeader() method. When the transport mechanism is something other than XMLHttpRequest (for example, a script tag for a JSONP request) the jqXHR object simulates native XHR functionality where possible.

    As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5). The.overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header:

    $.ajax({
      url: "http://fiddle.jshell.net/favicon.png",
      beforeSend: function ( xhr ) {
        xhr.overrideMimeType("text/plain; charset=x-user-defined");
      }
    }).done(function ( data ) {
      if( console && console.log ) {
        console.log("Sample of data:", data.slice(0, 100));
      }
    });
    // Assign handlers immediately after making the request,
    // and remember the jqxhr object for this request
    var jqxhr = $.ajax( "example.php" )
        .done(function() { alert("success"); })
        .fail(function() { alert("error"); })
        .always(function() { alert("complete"); });
    
    // perform other work here ...
    
    // Set another completion function for the request above
    jqxhr.always(function() { alert("second complete"); });

     参考:http://www.cnblogs.com/QLeelulu/archive/2008/04/21/1163021.html

  • 相关阅读:
    1. Dubbo原理解析-Dubbo内核实现之SPI简单介绍 (转)
    经典算法问题的java实现 (二)
    经典算法问题的java实现 (一)
    Bitmap的秘密
    Java Networking: UDP DatagramSocket (翻译)
    Java字节码浅析(二)
    Sql server 浅谈用户定义表类型
    Jquery 动态生成表单 并将表单数据 批量通过Ajax插入到数据库
    ASP.NET获取上传图片的大小
    ASP.Net大文件上传组件详解
  • 原文地址:https://www.cnblogs.com/youxin/p/2711890.html
Copyright © 2011-2022 走看看