/Examples/Example13/Scripts/FileUpload/backload.demo.js
https://github.com/amitrksharma/Backload · JavaScript · 63 lines · 31 code · 7 blank · 25 comment · 0 complexity · 6faa943c344273b432b02d42fb88617f MD5 · raw file
- /*
- * jQuery File Upload Plugin JS Example 8.0.1
- * https://github.com/blueimp/jQuery-File-Upload
- *
- * Copyright 2010, Sebastian Tschan
- * https://blueimp.net
- *
- * Licensed under the MIT license:
- * http://www.opensource.org/licenses/MIT
- */
- /*jslint nomen: true, regexp: true */
- /*global $, window, navigator */
- $(function () {
- 'use strict';
- var url = '/Backload/UploadHandler';
- // Initialize the jQuery File Upload widget:
- $('#fileupload').fileupload({
- // Uncomment the following to send cross-domain cookies:
- //xhrFields: {withCredentials: true},
- url: url
- });
- // Enable iframe cross-domain access via redirect option:
- $('#fileupload').fileupload(
- 'option',
- 'redirect',
- window.location.href.replace(
- /\/[^\/]*$/,
- '/cors/result.html?%s'
- )
- );
- // Load existing files by an initial ajax request to the server after page loads up
- // This is done by a simple jQuery ajax call, not by the FIle Upload plugin.,
- // but the results are passed to the plugin with the help of the context parameter:
- // context: $('#fileupload')[0] and the $(this)... call in the done handler.
- // With ajax.context you can pass a JQuery object to the event handler and use "this".
- $('#fileupload').addClass('fileupload-processing');
- $.ajax({
- // Uncomment the following to send cross-domain cookies:
- //xhrFields: {withCredentials: true},
- url: url,
- dataType: 'json',
- context: $('#fileupload')[0]
- }).always(function () {
- $(this).removeClass('fileupload-processing');
- }).done(function (result) {
- $(this).fileupload('option', 'done')
- .call(this, null, { result: result });
- });
- });
- $("document").ready(function () {
- $('#fileupload')
- .bind('fileuploaddestroy', function (e, data) {
- // Event handler example. Do something if you need after file has been deleted on the server.
- // (Refer to the client side documentatio).
- });
- });