Fixing jQuery Form Plugin Upload Responses
2010-11-23 22:11Android Certificate Installer uses jQuery Form Plugin ajaxForm to handle uploading and transloading certificates. The upload/transload response then provides the hash of the certificate. When tested, however, the response was surrounded by junk tags.
- <head></head><body>fd2ba47ae440c9405a573d0d03287f316dfe9eba</body>
Taking a look at the Form Plugin API, we see the plugin uses a hidden iframe to handle file uploads. A simple patch then adds the proper behavior. This patch is against version 2.49 of the un-minified plugin file.
- --- jquery.form.js 2010-11-06 14:16:53.792709557 -0400
- +++ /home/nicole/Projects/Sites/cooltrainer.org/js/jquery.form.js 2010-11-06 21:01:04.587884585 -0400
- @@ -349,7 +349,7 @@
-
- //log('response detected');
- cbInvoked = true;
- - xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
- + xhr.responseText = doc.body ? doc.body.innerHTML : doc.docElement ? doc.docElement.innerHTML : null;
- xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
- xhr.getResponseHeader = function(header){
- var headers = {'content-type': s.dataType};
The data is now returned un-altered.
- fd2ba47ae440c9405a573d0d03287f316dfe9eba