html - Javascript event after a form has been processed -
how javascript register callback run when server has completed processing form? particular setup:
<form id="saveplaylistform" name="saveplaylistform" target="saveplaylistiframe" method="post" action="<?=base_url()?>index.php/saveplaylist"> <input type="hidden" id="saveplaylistentire" name="saveplaylistentire" /> </form> <iframe id="saveplaylistiframe" name="saveplaylistiframe" style="display: none"> </iframe>
i've tried following no avail:
onsubmit
attaching onsubmit form not right event because onsubmit happens when client tries submit. server hasn't been contacted yet.
onload
i attached onload target iframe. doesn't fired in case. server script sets headers emulate m3u playlist file. iframes fire onload when normal html page loaded, not when file save dialog pops up. if load plain html page in iframe, onload fire first time user submits form. subsequent submissions won't fire onload.
this doesn't make sense though, submitting form reloads page new response. original document wouldn't exist anymore, how run callback?
you attach onsubmit handler cancels default submission action (by returning false) , replicate default browser submit making ajax call. have place attach response callback (by listening onreadystatechange, or using higher-level jquery).
Comments
Post a Comment