Javascript 使用ajaxphp上传文件
我正试图上传一个文件并通过AJAX发送。。但是我的错误率越来越低 注意:未定义索引:xlsFile in 下面是我的代码: HTML表单:(此表单在模式弹出窗口中)Javascript 使用ajaxphp上传文件,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我正试图上传一个文件并通过AJAX发送。。但是我的错误率越来越低 注意:未定义索引:xlsFile in 下面是我的代码: HTML表单:(此表单在模式弹出窗口中) 上载Excel文件: 提交 AJAX代码: <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> $(document).ready(function () { $("b
上载Excel文件:
提交
AJAX代码:
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).ready(function () {
$("button#addTripType").click(function(){
alert("hello");
$.ajax({
type: "POST",
url: "ajax-Upload.php", //
data: $('form.importModal').serialize(),
success: function(msg){
alert("success");
},
error: function(){
alert("failure");
}
});
});
});
</script>
$(文档).ready(函数(){
$(“按钮#添加TripType”)。单击(函数(){
警惕(“你好”);
$.ajax({
类型:“POST”,
url:“ajax Upload.php”,//
数据:$('form.ImportModel').serialize(),
成功:功能(msg){
警惕(“成功”);
},
错误:函数(){
警报(“故障”);
}
});
});
});
我该怎么办。。???需要帮助..???我也有同样的问题,如果您使用IE>=10,FormData也有可能。对于all和IE>=8,欺骗它的一种方法是在iframe中使用form 一种简单的方法是使用jquery.form插件: 您可以在表单中放置方法和操作:
<form id="form2" method="post" action="ajax-Upload.php" class="importModal" enctype="multipart/form-data">
Upload Excel File : <input type="file" name="xlsFile" id="xlsFile" />
<input type="submit" id="addType" name="addType" value="Submit" />
</form>
<form id="form2" method="post" action="ajax-Upload.php" class="importModal" enctype="multipart/form-data">
Upload Excel File : <input type="file" name="xlsFile" id="xlsFile" />
<input type="submit" id="addType" name="addType" value="Submit" />
</form>
$('#form2').submit(function() {
$(this).ajaxForm({
success: function(msg) {
alert("success");
},
error: function(){
alert("failure");
}
});
return false;
});