开发者

Callback for form submission (with jQuery)

I have a modal window that presents a form to users. The form includes one or more file uploads as well. Therefore I cannot submit the form with ajax.

At the moment I'm doing a standard submit with a submit button. When the form is submitted (which takes a few seconds in general), a PDF is generated and sent back for download (i.e. the Content-Disposition: attachment header), to force the download. Once the upload of the form data has completed, I need to close the modal window. If I call the close method straight way the submission never completes and the file download is never triggered (I think this is because the modal window is removed from the DOM). I can set a timeout, but there could be n number of images, so the time it takes to upload is unpredictable (and relative to the number of uploads).

I've looked at the jQuery form 开发者_如何学Cplugin (http://jquery.malsup.com/form/#file-upload), but apparently it uses an iframe to upload files, so I'm not sure if it will achieve what I need.

Thanks for any help,

Dom.


The Form plugin you mentioned should work - why do you suspect it won't?


Rewritten after rereading the question. Here's what I'd try:

  1. Serialize the form and make it the return value from the dialog, i.e. pass the data back to the page.
  2. Close the dialog
  3. Submit the serialized form
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜