I have a really large String that needs to be passed via input
tag in a html form
from client to server. Until now I've passed it just as a javascript var like this:
document.getElementById("editorText").value = quill.getText();
whereas the upload looks like this:
<form action="/someEndpoint" method="post">
<input class="btn btn-success btn-lg" style="margin-top: 15px;" type="submit" th:value="#{mSave}"/>
<textarea style="visibility:hidden" id="editorText" name="editorText"></textarea>
</form>
The problem with this is that the upload does not work this way when the quill.getText()
gets too large in size. I'd like to handle the upload via multipart file.
So what I need in this case is javascript code that takes the text from quill.getText()
, creates a file (preferably .xml) and servers this file for upload in the html form
mentioned above to a controller endpoint looking like this:
@RequestMapping(value = "/someEndpoint", method = RequestMethod.POST)
public String handleFileUpload(final Model model, @RequestParam("editorText") String editorText){
//handling stuff
}
I've tried something along the line of var xml = jQuery.parseXML(quill.getText())
but couldn't quiet get it to work.
Whats the simplest way to pack the string into a .xml file for upload?
ps: quill.getText()
is referring to this library
Edit 1: Changed the html input
to a textfield.