weixiyen / jquery-filedrop

jQuery plugin - drag and drop desktop files and POST to a URL to handle files.
958 stars 285 forks source link

responseType should not be hard coded as JSON #101

Open CuAnnan opened 11 years ago

CuAnnan commented 11 years ago

By adding responseType:'JSON' to the default_opts and adding an if statement to the xhr.onload which checks opts.responseType like so:

if(opts.responseType == 'JSON') { var result = opts.uploadFinished(index, file, jQuery.parseJSON(xhr.responseText), timeDiff); } else if(opts.responseType == 'XML') { var result = opts.uploadFinished(index, file, jQuery.parseXML(xhr.responseText), timeDiff); } else { var result = opts.uploadFinished(index, file, {}, timeDiff); }

you can allow response-agnostic uploading.