AjaxFileUpload return download panel when data is json
- by Tr.Crab
I use AjaxFileUpload (http://www.phpletter.com/Our-Projects/AjaxFileUpload/ ) to upload a file and get json result type response in struts2 ( code.google.struts2jsonresult.JSONResult )
but browser always pop-up download pane, plz give me some suggestions, thanks in advance
Here is my config in struts.xml :
......
<result-type name="json" class="code.google.struts2jsonresult.JSONResult">
............
<action name="doGetList" method="doGetList"
class="main.java.GetListAction">
<result type="json">
<param name="target">jsonObject</param>
<param name="deepSerialize">true</param>
<param name="patterns"> -*.class</param>
</result>
</action>
and js client :
function ajaxFileUpload(){
$("#loading").ajaxStart(function(){
$(this).show();
}).ajaxComplete(function(){
$(this).hide();
});
$.ajaxFileUpload
(
{
url:'doGetList.do',
secureuri:false,
fileElementId:'uploadfile',
dataType: 'json',
success: function (data, status)
{
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}
else
{
alert(data.msg);
}
}
},
error: function (data, status, e)
{
alert(e);
alert(data.records);
}
}
)
return false;
}