download file with submitToRemote
I'm in a jquery di开发者_如何学Goalog and I would like to download a file that requires a form submission within the dialog. I would like to use the g:submitToRemote tag to call the download but i'm not sure where to send the data since it's a ajax call. My current code is below...
GSP...
<g:submitToRemote class="download" controller="thingController" action="downloadInDialog" value=" " />
</div>
</g:form>
Controller...
def downloadInDialog = {
def thingInstance = Thing.get(params.id)
if (thingInstance) {
def fileResource = thingInstance.fileResource;
response.setContentType(fileResource.fileType);
response.setHeader("Content-disposition", "attachment;filename=${fileResource.name}")
response.outputStream << fileResource.toNewInputStream() // Performing a binary stream copy
}
}
I removed the submitToRemote and used a standard form submit in the jquery dialog and everything worked fine.
Thanks for everyone's help!
精彩评论