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

  • 相关阅读:
    cocos2d-x 3.0 事件分发机制
    cocos2d-x Schedule详解
    OSG设置警告等级
    OSG四元数与欧拉角之间的转换
    编译OSG_FBX插件
    RakNet发送与接收数据
    RakNet基本教程
    IE不能上网,但是其他浏览器可以
    OSG计时器与时间戳
    添加OSG各种事件处理器
  • 原文地址:https://www.cnblogs.com/youxin/p/2711890.html
Copyright © 2011-2022 走看看