javascript - formData object Uncaught TypeError: 非法调用
问题描述
虽然这个问题有很多帖子,但我仍然卡住无法解决这个问题。下面是我的简单代码。想将数据从csv导入mysql。
<div class="panel panel-default">
<div class="panel-heading">Import Data From Excel or CSV File to Mysql using PHPSpreadsheet</div>
<div class="panel-body">
<div class="table-responsive">
<span id="message"></span>
<form method="post" id="import_excel_form" enctype="multipart/form-
data">
<table class="table">
<tr>
<td width="25%" align="right">Select Excel File</td>
<td width="50%"><input type="file" name="import_excel" /></td>
<td width="25%"><input type="submit" name="import" id="import" class="btn btn-primary" value="Import" /></td>
</tr>
</table>
</form>
<br />
</div>
</div>
</div>
ajax调用下面的Javascript:
<script>
$(document).ready(function(){
$('#import_excel_form').on('submit', function(event){
event.preventDefault();
alert("lk");
$.ajax({
type:"GET",
url: "<?php echo base_url('billing/importsellcomCDR'); ?>",
data: new FormData(document.getElementById("import_excel_form")),
contentType: "application/json",
datatype: "json",
success: function(){
console.log("test");
},
error: function(xhr, textStatus, error){
console.log(xhr.statusText);
console.log(textStatus);
console.log(error);
}
});
});
});
</script>
它给出了错误 Uncaught TypeError: Illegal invocation 请知道我在哪里做错了。谢谢
解决方案
推荐阅读
- python - 具有较低的Python拆分方法
- c# - 如何防止 .NET Core 中的 MySqlConnector 类出现错误 CS0433?
- angular - ngrx 效果 - 两个 http api 效果相同
- oracle - 在连接和脚本执行后回到以前的 sql plus 会话可能吗?
- node.js - 使用 Nodejs 使用大对象 Postgres 存储文件
- git - 尝试更改旧提交消息时出错
- sql - 为什么我的 SQL 查询没有在休眠中返回任何结果?
- prometheus - 如何按值过滤即时向量然后在 promQL 中取范围?
- android - com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: 预期 BEGIN_OBJECT 但在第 1 行第 3 列路径 $[0] 处为 BEGIN_ARRAY
- python - 在白天和晚上重新采样 DataFrame