I have problem with my ajax posting. Ajax:
var formData = new FormData();
formData.append('file', files);
formData.append("url", url);
$.ajax({
url : "/servisDetail/uploadSoubor",
type : 'GET',
processData: false,
contentType: false,
data : formData,
success : function(response) {
console.log(response);
//vypisPrilohy(response);
},
error: function (xhr) { }
});
And java:
@RequestMapping(value = "/servisDetail/uploadSoubor", method= RequestMethod.GET)
public @ResponseBody
ModelMap servisDetailUploadFile(@RequestParam(value = "file",required = false) MultipartFile soubor,
@RequestParam(value = "url",required = false) String odkaz,
Locale locale){
ModelAndView model = new ModelAndView();
System.err.println("File: " + soubor + " and " + odkaz);
return model.getModelMap();
}
But print to console is: File: null and null.
Without processData: false I have ajax error: Illegal invocation and type get or post is still same
Does anyone know how to fix it?