jQuery and the Form plugin: download files


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
10 views
So the problem is:

Doing the form submission to the server through the method ajaxSubmit() plugin mentioned above. Forms without file element work good. The result is returned as a JSON string.

Problems arise when the form is added to the file selection. In form template I have a gun get each enctype. The plugin sends all, the result comes in the right view (looking through firebug). First problem — the browser offers to save the result as a file. Googling, I came to the conclusion that the Content-Type of the response had to change from 'application/json; charset=UTF-8' default to 'text/html; charset=utf-8'.

Now the answer comes "Studio", but the success function doesn't work. Apparently, now bung in the format of the expected result — I pointed out the option dataType: 'json'. Removed the option — success work out, but, apparently, the plugin tries to convert the result to html format, because it adds tags of type HEAD and BODY. And firebug shows that the initial result came true, ie it cant exactly plug-in.

Has anyone met with such problems? How to solve them? Using jQuery 1.4.2 (tried to switch to 1.3.2 — the same rake), and Form 2.5.1 (such as the last version).
by | 10 views

4 Answers

0 like 0 dislike
Really... I too had problems with the upload of the file, just as I decided I do not remember, so I thought maybe it helped.
by
0 like 0 dislike
What is not a suitable method ajaxForm?
by
0 like 0 dislike
This is due to the fact that the only cross-browser method of downloading files AJAX'om — create invisible />and specify the form attribute target="upload".
Plug-in this the response is read only as text.
\r
The solution is to parse the JSON yourself.
by
0 like 0 dislike
As I recall the problem is in firebug'E. Try with disabled firebug'ohms. The thing is, ka is mentioned above, the form is sent to iframe and the plugin takes document.body.innerHTML and our beloved firebug adds a couple of my DIVS in an iframe is not valid json.
There is a way using a textarea or an answer to not just return json, and json is wrapped in "pre".
But it's firebug'e, that is, there are people inspected your website using firebug, then it will not work.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
27,842 users