I wrote a upload script using dojo and form:
HTML
<form action="/Form/Upload" enctype="multipart/form-data" id="FormId" method="post">
<input id="..." name="..." type="file" onchange="UploadImage(this, FormId);" />
</form>
Dojo
require([
"dojo/dom-attr",
"dojo/request/iframe"],
function (domattr, iframe) {
UploadFile = function (Uploader, form) {
if (Uploader.value != "") {
if (Uploader.files[0].size < 50000000) {
iframe(form.formAction, {
form: form,
handleAs: "text",
timeout: 20000,
method: "POST"
}).then(function (name) {
.
.
.
}, function (err) {
.
.
.
});
}
}
};
};
For some reason I get an error
Uncaught SyntaxError: Unexpected token ILLEGAL
But this does not happen every time! After I refresh the page it sometimes works and some times gives an error. Then I run debugger in chrome it doesn't even get to dojo. It throws an error on the <form>
row. (all the dots is a irrelevant code because it doesn't get to that point when the error is thrown but is works perfectly after I refresh the page)