单位的系统只能在IE9及以下的的浏览器使用,IE9以下不支持FORMDATA等等,所以文件上传只能考虑不需FORMDATA的,用了AJAXSUBMIT,但在回调SUCCESS中无法获取返回的数据,跟踪到返回数据为空白,始终不晓得有什么问题,哪位有经验帮帮忙。谢谢
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.form.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<!--- <script type="text/javascript" src="formdata.js"></script> -->
<title>PON口割接资料处理</title>
<script type="text/javascript">
var base='${base}';
function uploadfile(param)
{
$('#uploadform1').ajaxSubmit({
url:base+'/update/updatefile',
type:"post",
beforeSubmit:function(){
return checkfile(param);
},
success:OnSuccess,
error:function()
{
alert("系统出错");
}
});
function OnSuccess(responseText, statusText, xhr, $form)
{
if(responseText.error!=" ")//在这里,responseText显示为空
alert(responseText.error);
}
function checkfile(param)
{
var filename=$("#upload1").val();
var fileext=filename.replace(/.+\./,"");
if(filename=="")
{
alert("请选择文件");
return false;
}
if(fileext=="xls")
{
return true;
}
else
if(fileext=="xlsx")
return true;
else
{
alert("请选择EXCEL文件");
return false;
}
}
function uploadfile1()
{
uploadfile($('#upload1'));
}
function uploadfile2()
{
uploadfile($('#upload2'));
}
</script>
</head>
<body>
<h4 align="center">PON口割接资料处理</h4>
<form id="uploadform1" enctype="multipart/form-data">
请选择分局提交的EXCEL文档,勿做任何修改:
<input type="file" name="upload1" id="upload1" width="520px">
<input id="uploadfile_id" value="上传" type="button" onclick="uploadfile1()"/>
</form>
<br>
<div id="uploadform2" >
请选择资源提交的EXCEL文档,勿做任何修改:
<input type="file" name="upload2" id="upload2" width="520px">
<input id="uploadfile_id" value="上传" type="button" onclick="uploadfile2()"/>
</div>
</body>
</html>
后台返回的为一Json.tojson(nutMap1);
nutMap1内为{”error":" ","newoltpon":"sdghfjsgf"}这一类数据。
我想在前台JSP内拿到nutMap1的返回数据,判断error为OK,则往下走,否则显示ERROR的数据告知操作员