オリジナル
次のように、Javascript アプリでその場でPapaparseをロードしています。
$.getScript('path/to/papaparse.js',function() {
//below script
});
次に、このように解析するファイルを取得します。
$('#csv_file').parse({
delimiter: ",",
worker: true,
skipEmptyLines: true,
before: function(file,inputElement) {
console.log(file);
console.log(inputElement);
},
error: function(err, file, inputElement, reason) {
console.log('error');
console.log(err);
console.log(file);
console.log(inputElement);
console.log(reason);
},
step: function(results,parser) {
console.log(results);
console.log(parser);
},
complete: function(results,file) {
console.log(results);
console.log(file);
}
});
-callbackconsole.log
内のmyはどれも起動しませんが、 - および-callback から出力されます。step
before
complete
before:
file:
File {}
lastModified: 1437396586321
lastModifiedDate: Mon Jul 20 2015 14:49:46 GMT+0200 (South Africa Standard Time)
name: "normal.csv"
size: 254743
type: "application/vnd.ms-excel"
webkitRelativePath: ""
inputElement:
<input type="file" name="csv_file" id="csv_file" class="form-control half">
complete:
results: undefined
file: undefined
a)コールバックで何も返されない理由と、 b)コールバックで返される理由を教えてもらえますか?step
undefined
complete
アップデート
SCRIPT_PATH
コメントで提案されているように、次のように追加しました。
$.getScript('path/to/papaparse.js',function() {
Papa.SCRIPT_PATH = config.basedir + '/app/lib/papaparse/papaparse.min.js';
// Papa script
});
そして、私の前をこれに変更しました:
before: function(file,inputElement) {
console.log(file);
console.log(inputElement);
return { action : 'continue' }
},
ただし、まだ未定義になります。