Currently working on a dropzone functionality with the spring MVC framework.
This is the method in the controller class ( I'm using internal view resolver)
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public String save(MultipartHttpServletRequest request,
HttpServletResponse response, Model map) {
//The logic for adding file to db and creation of json object here
.....
.....
userDataJSON = strWriter.toString();
return userDataJSON;
}
Here is my javascript for the dropzone upload
Dropzone.options.myAwesomeDropzone = {
maxFilesize : 2,
addRemoveLinks : true,
uploadMultiple : true,
init : function() {
this.on("addedfile", function(file) {
$.ajax({
method : 'get'
}).done(function( data, textStatus, xhr ) {
alert(data);
//Expecting the json objec here
});
});
}
};
Here i'm not getting the json reponse, from the controller.
Please let me know if you have any solutions for me. Thanks in advance.
$.ajax
seems strange unless you have a global setting – Retrieve$.ajax
requires a url either set in a global setting or within each call. Assume answer is yes to request being made to correct url? – Retrieveon("addedFile")
is very suspect. Sugegst you read plugin docs more thoroughly – Retrieve