【发布时间】:2014-06-24 05:14:59
【问题描述】:
我正在尝试将 json 数组发送到 upload.php 文件。弹出如下错误:
未捕获的类型错误:非法调用
我也尝试添加processData: false,但是没有任何内容发布到upload.php。
我的代码:http://jsfiddle.net/r0330537/86yqj/
HTML
<div id="dropzone" class="dropzone">
Drop uw bestanden en/of zip hier
</div>
JQUERY
$( document ).ready( function() {
...
function drop(event) {
//console.log( "drop", event );
event.stopPropagation();
event.preventDefault();
$(this).removeClass("dragging");
var data = event.dataTransfer,
fileList = data.files,
file = new Array();
for(i = 0; i < fileList.length; i++) {
file.push( fileList[i] );
}
console.log( file );
// ajax
$.ajax({
type : "POST",
url : "ajax/upload.php",
dataType : "json",
data : { "file": file },
succes : function(data) {
console.log(data);
}
});
}
var dropzone = $( ".dropzone" ).get(0);
...
dropzone.addEventListener( "drop", drop, false );
});
【问题讨论】:
标签: php jquery ajax arrays json