From 018d1c02ccb8bf2d104ff307622184d2b64d95fd Mon Sep 17 00:00:00 2001 From: bangbang93 Date: Wed, 26 Nov 2014 21:24:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=89=8B=E7=99=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jquery.upload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.upload.js b/jquery.upload.js index 9818739..888c170 100644 --- a/jquery.upload.js +++ b/jquery.upload.js @@ -15,7 +15,7 @@ params: {}, onSend: noop, onSubmit: noop, - onComplate: noop + onComplete: noop }; $.upload = function(options) { @@ -53,7 +53,7 @@ if ('json' == opts.dataType) { data = window.eval('(' + data + ')'); } - opts.onComplate(data); + opts.onComplete(data); setTimeout(function() { iframe.remove(); form.remove(); From 5cbf08adfda5225d49f80473de9ee21c31c43bcd Mon Sep 17 00:00:00 2001 From: bangbang93 Date: Wed, 26 Nov 2014 21:29:37 +0800 Subject: [PATCH 2/4] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 256259f..6cd38d1 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ jquery async upload plugin easy to use // 上传方法 +```javascript $.upload({ // 上传地址 url: '/admin/upload', @@ -16,7 +17,8 @@ easy to use return true; }, // 上传之后回调 - onComplate: function(data) { + onComplete: function(data) { alert(data); } - }); \ No newline at end of file + }); +``` From 3dbce870735ae01ff141ff2e0cce23392bccc3dd Mon Sep 17 00:00:00 2001 From: bangbang93 Date: Thu, 27 Nov 2014 00:35:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E4=BC=9A=E6=B1=A1=E6=9F=93=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E7=9A=84for=E5=BE=AA=E7=8E=AF=20=E4=BF=AE=E6=94=B9iframe.onloa?= =?UTF-8?q?d=E4=B8=BAiframe.on('load')=EF=BC=8C=E5=85=BC=E5=AE=B9zepto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jquery.upload.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.upload.js b/jquery.upload.js index 888c170..8b165d4 100644 --- a/jquery.upload.js +++ b/jquery.upload.js @@ -20,7 +20,7 @@ $.upload = function(options) { var opts = $.extend(jQuery.uploadDefault, options); - if (opts.url == '') { + if (!opts.url) { return; } @@ -36,7 +36,7 @@ // form中增加数据域 var formHtml = ''; - for (key in opts.params) { + for (var key in opts.params) { formHtml += ''; } form.append(formHtml); @@ -47,7 +47,7 @@ form.submit(opts.onSubmit); // iframe 在提交完成之后 - iframe.load(function() { + iframe.on('load', function() { var contents = $(this).contents().get(0); var data = $(contents).find('body').text(); if ('json' == opts.dataType) { From cb1415a3b1d879d489770d12f6b39f3369d4bb37 Mon Sep 17 00:00:00 2001 From: bangbang93 Date: Thu, 27 Nov 2014 00:35:50 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8E=BB=E9=99=A4eval=E8=BD=AC=E6=8D=A2jso?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jquery.upload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.upload.js b/jquery.upload.js index 8b165d4..fb22103 100644 --- a/jquery.upload.js +++ b/jquery.upload.js @@ -51,7 +51,7 @@ var contents = $(this).contents().get(0); var data = $(contents).find('body').text(); if ('json' == opts.dataType) { - data = window.eval('(' + data + ')'); + data = JSON.parse(data); } opts.onComplete(data); setTimeout(function() {