我已經建立了一個非常簡單的原型來測試出YUI上傳「上傳」事件。 (flash版本)該文件正在發送一個簡單的Ajax響應的服務器。但是,唯一觸發的事件是fileselect
和uploadstart
。 uploadcomplete
,uploaderror
和uploadprogress
從不觸發。這是YUI 3.5.1。YUI 3 UploaderFlash不點火
HTML和JS
<!DOCTYPE html>
<html>
<head>
<title>Uploader Bizness</title>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
</head>
<body>
<div id="upload"></div>
<div id="progress"></div>
<script>
'use strict';
YUI().use('uploader', 'uploader-flash', function (Y) {
Y.Uploader = Y.UploaderFlash;
var uploader = new Y.Uploader({
width: '150px',
height: '40px',
swfURL: '/flashuploader.swf'
}).render('#upload');
uploader.on('fileselect', function (G) {
var firstFile = G.fileList[0];
uploader.upload(firstFile, 'http://localhost:28107/home/upload', { postvar1: 'foo', postvar2: 'bar' });
});
uploader.on('uploadstart', function() {
console.log('Upload started');
});
uploader.on('uploadcomplete', function (e) {
console.log('Upload completed successfully', e);
});
uploader.on('uploaderror', function (e) {
console.log('Upload error', e);
});
uploader.on('uploadprogress', function (file, bytesloaded, bytesTotal, percentLoaded, e) {
$('#progess').html(percentLoaded);
});
});
</script>
</body>
</html>
服務器端代碼
public JsonResult Upload()
{
var result = new JsonResult();
result.Data = new {message = "great success"};
return result;
}
我在做什麼錯在這裏?
被任何機會混淆返回JSON Flash上傳?我遇到了'__flash__toXML'問題,就像[here](http://stackoverflow.com/questions/7235631/yui3-uploader-rails-rjs)。 – Arjan