I’ve got following html doc for ajax file uploads:
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.form.js" type="text/javascript"></script>
<script type="text/javascript">
$ (document).ready(function() {
$ ('#file_upload_form').ajaxForm({
success: function(data, textStatus, jqxhr) {
if (data.redirect)
window.location.replace(data.redirect);
else
alert(data.text);
},
error: function(jqXHR, textStatus, errorThrown) {
alert("unexpected error: " + textStatus);
},
dataType: "json",
});
});
</script>
</head>
<body>
<form id="file_upload_form" action="http://apddr/pl/administration/test/" method="post" enctype="multipart/form-data">
<table class="grey" id="file_table">
<tr>
<th colspan="2">
Add file
</th>
</tr>
<tr>
<td style="vertical-align: top; width: 10em;" class="strong"><label for="id_file">File name:</label></td>
<td>
<input type="file" name="file" size="50" id="id_file" style="background-color: initial;"/><br />
</td>
</tr>
<tr>
<td class="strong">
<label for="id_language">Choose lang:</label>
</td>
<td>
<select id="id_language" name="language">
<option value="">-- no language --</option>
<option value="ANG">english</option>
<option value="NIE">german</option>
</select>
</td>
</tr>
<tr>
<td class="strong"><label for="id_description">Description:</label></td>
<td>
<input class="text" type="text" name="description" maxlength="300" id="id_description" style="width: 100%;"/><br />
</td>
</tr>
<tr>
<td class="strong"></td>
<td class="strong" style="text-align: right">
<input type="submit" class="submit" name="addFile" value="Send" />
</td>
</tr>
</table>
</form>
</body>
</html>
Calling http://apddr/pl/administration/test/ returns application/json ‘{‘text’: ‘test’}’.
Under Chromium alert(“unexpected error: ” + textStatus); line is called with textStatus=’aborted’ what is unwanted, but firefox is downloading this JSON. In addition, in firebug console it instantly prints:
[jquery.form] state = uninitialized
What am I doing wrong? Help!