zoukankan      html  css  js  c++  java
  • jQuery FileUpload doesn't trigger 'done'

     

    If your server is not returning JSON, try removing:

    dataType: 'json'

    Otherwise you may be ending up with a fail event, which is easy to test for:

    fail: function(e, data) {
      alert('Fail!');
    }

    https://github.com/blueimp/jQuery-File-Upload/wiki/Options#datatype

    AJAX Options

    The jQuery File Upload plugin makes use of jQuery.ajax() for the file upload requests. This is true even for browsers without support for XHR, thanks to the Iframe Transport plugin.

    The options set for the File Upload plugin are passed to jQuery.ajax() and allow to define any ajax settings or callbacks.
    The ajax options processData, contentType and cache are set to false for the file uploads to work and should not be changed.
    The timeout setting is set to 0. See pull request #3399 for the reasoning behind this. The following options are also set by the plugin, but can be useful to customize:

     

    url

    A string containing the URL to which the request is sent.
    If undefined or empty, it is set to the action property of the file upload form if available, or else the URL of the current page.

    • Type: string
    • Example: '/path/to/upload/handler.json'

     

    type

    The HTTP request method for the file uploads. Can be "POST", "PUT" or "PATCH" and defaults to "POST".

    • Type: string
    • Example: 'PUT'

    Note:
    "PUT" and "PATCH" are only supported by browser supporting XHR file uploads, as iframe transport uploads rely on standard HTML forms which only support "POST" file uploads. See Browser support.
    If the type is defined as "PUT" or "PATCH", the iframe transport will send the files via "POST" and transfer the original method as "_method" URL parameter.

    Note: As was noted above, it's a common practice to use "_method" to transfer the type of your request. For example, "Ruby on Rails" framework uses a hidden input with the name "_method" within each form, so it will likely override the value that you will set here.

     

    dataType

    The type of data that is expected back from the server.

    Note: The UI version of the File Upload plugin sets this option to "json" by default.

      • Type: string
      • Example: 'json'

    done

    Callback for successful upload requests. This callback is the equivalent to the success callback provided by jQuery ajax() and will also be called if the server returns a JSON response with an error property.

    • Example:
    function (e, data) {
        // data.result
        // data.textStatus;
        // data.jqXHR;
    }
  • 相关阅读:
    UML的现状及未来发展
    终于申请好了Blog。:)
    2004年最后一场雪
    今天开始在乐世安通上班了
    狐狸与兔子问题
    今天上午
    好久没更新了啊,写写近况
    还是得考研啊!
    kettle HTTP client
    国外的一个PIC源代码网站,比较不错,基于HiTech C的。共享一下
  • 原文地址:https://www.cnblogs.com/chucklu/p/11060491.html
Copyright © 2011-2022 走看看