title: jQuery error: TypeError: a is undefined in jquery-file-upload
body: <p>I have added jQuery-File-Upload to an employment app I am creating. I have the files uploading and saving. I am however getting an error when processing the returned JSON. The button doesn't clear saying "abort" and the rest of the script fails. </p>
  
  <p>I am getting this error reported in FireBug: </p>
  
  <pre><code>TypeError: a is undefined
  ...rCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f&gt;e;e...
  </code></pre>
  
  <p>After this JSON is returned:</p>
  
  <pre><code>[{"name":"New Upload Complete:   a9chafa8d62591feca73c5227473d3d4307contact-mri.png","size":"16.88kB","type":"image\/png","delete_url":"\/ch\/upload","delete_type":"DELETE","url":"\/"}]
  </code></pre>
  
  <h2>I welcome any advice or direction!</h2>
  
  <p>Edited:
  Here is the code that I am using for jQuery-file-upload:</p>
  
  <pre><code>&lt;script src="/js/vendor/jquery.ui.widget.js"&gt;&lt;/script&gt;
  &lt;!-- The Load Image plugin is included for the preview images and image resizing functionality --&gt;
  &lt;script src="//blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"&gt;&lt;/script&gt;
  &lt;!-- The Canvas to Blob plugin is included for image resizing functionality --&gt;
  &lt;script src="//blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js"&gt;&lt;/script&gt;
  &lt;!-- The Iframe Transport is required for browsers without support for XHR file uploads --&gt;
  &lt;script src="/js/jquery.iframe-transport.js"&gt;&lt;/script&gt;
  &lt;!-- The basic File Upload plugin --&gt;
  &lt;script src="/js/jquery.fileupload.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload processing plugin --&gt;
  &lt;script src="/js/jquery.fileupload-process.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload image preview &amp; resize plugin --&gt;
  &lt;script src="/js/jquery.fileupload-image.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload audio preview plugin --&gt;
  &lt;script src="/js/jquery.fileupload-audio.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload video preview plugin --&gt;
  &lt;script src="/js/jquery.fileupload-video.js"&gt;&lt;/script&gt;
  &lt;!-- The File Upload validation plugin --&gt;
  &lt;script src="/js/jquery.fileupload-validate.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  /*jslint unparam: true, regexp: true */
  /*global window, $ */
  $(function () {
      'use strict';
      // Change this to the location of your server-side upload handler:
      var uploadurl = "/upload/index/token/&lt;?php echo $this-&gt;token; ?&gt;" ,
  
  
              uploadButton = $('&lt;button/&gt;')
              .addClass('button button-primary')
              .prop('disabled', true)
              .text('Processing...')
              .on('click', function () {
                  var $this = $(this),
                      data = $this.data();
                  $this
                      .off('click')
                      .text('Abort')
                      .on('click', function () {
                          $this.remove();
                          data.abort();
                      });
                  data.submit().always(function () {
                      $this.remove();
                  });
              });
  
      $('#fileupload').fileupload({
          url: uploadurl,
          dataType: 'json',
          autoUpload: false,
          acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
          maxFileSize: 999000,
          // Enable image resizing, except for Android and Opera,
          // which actually support image resizing, but fail to
          // send Blob objects via XHR requests:
          disableImageResize: /Android(?!.*Chrome)|Opera/
              .test(window.navigator.userAgent),
          previewMaxWidth: 100,
          previewMaxHeight: 100,
          previewCrop: true
      }).on('fileuploadadd', function (e, data) {
          data.context = $('&lt;div/&gt;').appendTo('#files');
          $.each(data.files, function (index, file) {
              var node = $('&lt;p/&gt;')
                      .append($('&lt;span/&gt;').text(file.name));
              if (!index) {
                  node
                      .append('&lt;br&gt;')
                      .append(uploadButton.clone(true).data(data));
              }
              node.appendTo(data.context);
          });
      }).on('fileuploadprocessalways', function (e, data) {
          var index = data.index,
              file = data.files[index],
              node = $(data.context.children()[index]);
          if (file.preview) {
              node
                  .prepend('&lt;br&gt;')
                  .prepend(file.preview);
          }
          if (file.error) {
              node
                  .append('&lt;br&gt;')
                  .append($('&lt;span class="text-danger"/&gt;').text(file.error));
          }
          if (index + 1 === data.files.length) {
              data.context.find('button')
                  .text('Upload')
                  .prop('disabled', !!data.files.error);
          }
      }).on('fileuploadprogressall', function (e, data) {
          var progress = parseInt(data.loaded / data.total * 100, 10);
          $('#progress .progress-bar').css(
              'width',
              progress + '%'
          );
      }).on('fileuploaddone', function (e, data) {
          $.each(data.result.files, function (index, file) {
              if (file.url) {
                  var link = $('&lt;a&gt;')
                      .attr('target', '_blank')
                      .prop('href', file.url);
                  $(data.context.children()[index])
                      .wrap(link);
              } else if (file.error) {
                  var error = $('&lt;span class="text-danger"/&gt;').text(file.error);
                  $(data.context.children()[index])
                      .append('&lt;br&gt;')
                      .append(error);
              }
          });
      }).on('fileuploadfail', function (e, data) {
          $.each(data.files, function (index) {
              var error = $('&lt;span class="text-danger"/&gt;').text('File upload failed.');
              $(data.context.children()[index])
                  .append('&lt;br&gt;')
                  .append(error);
          });
      }).prop('disabled', !$.support.fileInput)
          .parent().addClass($.support.fileInput ? undefined : 'disabled');
  });
  &lt;/script&gt;
  </code></pre>