zoukankan      html  css  js  c++  java
  • Jquery调用ajax参数说明

    代码中有详细注释,直接上代码。

    注释掉的选项,一般用不到,直接用最基本的部分就可以了。

                $.ajax({
                    // 请求的URL
                    url: '../Daily/Daily_Report',
    
                    //HTTP method:"POST", "GET", "PUT"
                    // 这样写也行 method: 'POST',
                    type: "POST",
    
                    // 发送到服务器的数据
                    data: {
                        "user":"abc"
                    },
    
                    // default: true
                    // 是否异步,默认是异步的
                    //async: true,
                    
                    // default: true
                    // 发送数据前,会将data属性指定的object转换成query string
                    // 指定成false后,object的数据在后台得不到
                    //processData: true,
    
                    // default: 'application/x-www-form-urlencoded; charset=UTF-8'
                    // values: application/x-www-form-urlencoded, multipart/form-data, or text/plain
                    // 发送给服务器的数据类型,UTF-8编码是固定的,改不了的。
                    // 设定为false,就是不设定contentType给服务器,可以省略
                    //contentType: false,
    
                    // 服务器返回的数据类型,不指定的话,jquery回根据服务器指定的MIME进行推断。
                    // 所以,如果服务器指定了MINE类型,可以省略
                    //dataType:"json",
    
                    // 发送前调用的函数
                    // 如果返回false,将取消ajax请求
                    //beforeSend: function (xhr, settings) {
                    //},
    
                    // 对返回数据的预处理
                    // 这里的data是原始的response的数据,比success函数的data要早,
                    // 如有需要,可以对返回的原始值进行处理,然后再返回data
                    //dataFilter:function(data, type){
                    //},
    
                    // 成功时调用的函数
                    // 这里的data已经是根据dataType,格式化好的数据,比如一个json对象。
                    success: function (data, textStatus, xhr) {
                        if (data !== null) {
                        }
                    },
    
                    // 异常时调用的函数
                    //  Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror".
                    // When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error."
                    error: function (xhr, textStatus, errorThrown) {
                    },
    
                    // ajax请求完成调用的函数,这个函数在success和error后调用,不论成功或失败都要做的操作放在这里
                    //textStatus:"success", "notmodified", "nocontent", "error", "timeout", "abort", or "parsererror"
                    complete: function(xhr, textStatus){
                    }
                });
  • 相关阅读:
    数据库规范化与经典三范式
    左右两个下拉框里的内容互换
    利用创造元素的方法进行下拉框内容的添加
    数组除重和应用随机数进行随机点名
    for 语句练习
    super和this
    linux常用命令
    g​e​t​A​t​t​r​i​b​u​t​e​和​g​e​t​P​a​r​a​m​e​t​e​r​区​别
    HTTP 方法:GET 对比 POST
    sql语句中字符串类型的变量前后需要使用单引号
  • 原文地址:https://www.cnblogs.com/xiashengwang/p/8085140.html
Copyright © 2011-2022 走看看