发布的数据来自FORMDATA,但没有发布

时间:2017-07-14 15:53:36

标签: php jquery ajax post form-data

我正面临着ajax请求的这个奇怪问题

if (e.target.files != undefined) {
            var reader = new FileReader();
            reader.onload = function (e) {
                $.ajax({
                    url: Routing.generate('test_ajax_data'),
                    data: e.target.result,
                    processData: false,
                    type: 'POST',
                    success: function (data) {
                        $('#voucherCount').text('Count of records that will be uploaded : ' + data.count);
                    }
                });
            };
            reader.readAsText(e.target.files.item(0));
        }

我收到的输出:

show

虽然当我在做print_r($ _ POST)时,我得到一个空数组。

1 个答案:

答案 0 :(得分:0)

尝试了你的代码,工作正常,

不能真正解决您的问题,但我认为您应该查看HTML5 File API - Send file to server for processing enter image description here