Ok, after large amounts of debugging and thinking things through, my
co-worker (who originally wrote the piece we're working on) noticed
that we close the modal dialog in which our form resides after we make
our call to submit.  This makes perfect sense because the modal is no
longer needed after the form submits, and once the form submit line
has completed, the data is away to the server leaving us no need for
anything in the modal.

That is until you use the form plugin on a form with a file input.
The fileUpload() function in that plugin moves some of the form
submission process into a setTimeout, causing it to happen
asynchronously.  So our submit line completes and our script moves on
and closes the modal--ripping the form out of the DOM.  THEN what the
plugin dropped into the setTimeout executes and guess what--there's
nothing left for it to work with.

To the plugin author: you should document this on your site in the
section about file uploads.  The move of a chunk of code into an
asynchronous place of execution has some implications which should be
brought to the attention of those working with your plugin.

Thanks,
Jim


On Apr 27, 9:09 pm, Jim <auldrid...@gmail.com> wrote:
> I'm using the latest version of the form plugin 
> fromhttp://jquery.malsup.com/form/
> and am having problems with a form that has an input of type "file".
>
> I have read all the info about how to return JSON and such, how an
> iframe is used, etc.  I've Googled around and searched this list, but
> m not seeing anything relating to my problem.
>
> I have a series of forms which pop up in a modal dialog and are
> submitted view the ajaxSubmit method.  Only one of these forms has a
> file field in it, and it does not work at all.  Upon hitting submit, I
> see no network activity in the Firebug console, though I didn't really
> expect any given that this uses the iframe.   However, the Net panel
> of Firebug shows no activity either.  Further, the PHP file at which
> this form is pointed has a LOT of debug statements in it, and none of
> them show up in the logs when I it submit.
>
> I added some debugging to the ajax-on-error method I'd set for this
> call by adding a console.log() of the error text and the error object
> which are passed to the error function and they say
>
> "error"
>
> and
>
> "SyntaxError"  "()@:0\neval(\"()\")@:0\n([object Object],\"json\")
> @https://jauldridge.yakabod.net/js/vne/jquery/core/jquery.js:29\ncb(-5)
> @https://jauldridge.yakabod.net/js/vne/jquery/plugins/form/
> jquery.form.js:305\n"
>
> respectively.    adding a consol.log() of the XHR object which is
> passed to the error function shows the mock object and it is still
> empty.
>
> Line 305 of the form plugin seems to be what is referenced in the odd
> output of the error object, along with line 29 of jQuery.  Line 305 of
> the form plugin is a call to jQuery's httpData method which is defined
> on line 29 of jQuery.  Line 305 of the form plugin is supposed to be
> taking what was retrieved from the textarea (I'm using JSON) of the
> iframe and passing it to jQuery with my specified data type for
> parsing.  Since this is all happening without any network activity,
> and the mock object shows it is empty including its responseText, I
> imagine that is why jQuery's httpData method is getting an error in
> trying to parse JSON.
>
> I just cannot figure this out, and I'd really like some help.  Why is
> the plugin acting like it is done submitting when it hasn't even tried
> to talk to the server?  This system is on a private network so I
> cannot link to it, but I will provide as much info as is asked for and
> I can obtain.
>
> Thanks,
> Jim

Reply via email to