[Xsltforms-support] form submission via JavaScript, co-existence w/ jQuery
Brought to you by:
alain-couthures
From: Adam M. <Ada...@gm...> - 2013-03-24 13:40:24
|
Hi, << This time I'm posting in plain text, which should work better! >> A few months ago I asked for some advice about invoking JavaScript to handle form submission. I'd like to restate the problem I encountered, share my work-around, and ask again for input. I wanted to pass the instance data (serialized as xml) to a JavaScript function, and let it handle the submission from there. The problem I encountered is that I could only use the 'get' submission method with JavaScript, and with 'get' the instance data would be URL-encoded and appended to the 'action', which is a problem if the action is 'javascript:submit(ser);'. Looking at xsltforms.js, the line in XsltForms_submission.prototype.submit that invokes JS is this one: eval("ser = (" + action.substr(11) + ");"); So my work-around is to make the garbage appended to the action harmless by making it a comment: <xf:submission id='submit' method='get' relevant='true' replace='instance' serialization='application/xml' action='javascript:submit(ser));//' /> The line of JS eval'd might be something like: ser = (submit(ser));//?var1=val1&var2=val2... Would it be OK to change the code so it never appends URL-encoded instance data to an action that starts with 'javascript:' ? Also, can XSLTForms co-exist with jQuery now? Currently I put my forms into iframes, which is mostly OK, but it would be nice in future to have everything in one integrated page. Thanks very much! /A |