Here is my ajax code
$('.AllTaskDownloadButton').live('click', '.CheckBoxesForDownload', function(){
var n = $( "input:checked.CheckBoxesForDownload" ).length;
var arr=[]
for(i=0;i<n;++i){
arr.push($($( "input:checked.CheckBoxesForDownload" )[i]).val())
}
alert(arr)
//passing requestId to servlet
$.ajax({
url:"/test/DownloadDeleteTask",
type:"POST",
dataType:'json',
data: {requestIds:arr,
operationType:'download' },
success:function(result){
alert(result);
dowloadTasks();
}
});//ajax
});
and here is my servlet code:
PrintWriter out = response.getWriter();
String operationType = request.getParameter("operationType");
if (operationType.equalsIgnoreCase("download")) {
out.print("download");
}// if
but my downloadTasks()
is not getting called.
please help to FIX the issue?
stringify the json in the data part of the ajax call and add contentType:
$.ajax({
url: "/test/DownloadDeleteTask",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({requestIds:arr,
operationType:"download"
}),
success:function(result){
alert(result);
dowloadTasks();
}
});