AjaxFileUpload return download panel when data is json
Posted
by Tr.Crab
on Stack Overflow
See other posts from Stack Overflow
or by Tr.Crab
Published on 2010-04-07T06:06:45Z
Indexed on
2010/04/07
6:13 UTC
Read the original article
Hit count: 276
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;
}
© Stack Overflow or respective owner