I'm new to jsp, so I'd like to know how to return a response to AJAX. This is the code to submit the form using dojo with AJAX:
<script type="text/javascript">
dojo.require("dojo.io.iframe");
dojo.addOnLoad(function() {
upload = function( ) {
dojo.io.iframe.send({
form : "fileUploader",
handleAs : "html", //response type from the server
url : "url to jsp",//just example, not the real url
load : function(response, ioArgs) {
console.log(response, ioArgs);
return response;
},
error : function(response, ioArgs) {
console.log("error");
console.log(response, ioArgs);
return response;
}
});
};
});
and this is the fragment of the jsp code to return the response:
r = "<p >You have successfully uploaded your video. </p>";
response.setContentType("text/html");
response.getWriter().write(r);
if I just use System.out.println(r), it does print the result in console, so the form is being submitted. So I think the problem is the way I'm returning the response or the way I'm handling it with dojo.
Thanks in advance!