I have an image upload function that uploads form with image like this:
iframe(url, {
form: dom.byId("myform"),
handleAs: "json",
timeout: 5000,
method: "POST"
}).then(function () {
console.log("Success");
}, function (Err) {
console.log(Err);
});
On server side I get the image, but on client side I get TypeError: Cannot read property 'value' of undefined↵ at I [as handleResponse] (http://ajax.googleapis.com/ajax/libs/dojo/1.9.2/dojo/request/iframe.js:9:114)↵ at r (http://ajax.googleapis.com/ajax/libs/dojo/1.9.2/dojo/dojo.js:206:81)". I have no returned value! I do not get what causing the error! Please help!
From the Dojo Reference Guide:
All you should need to do to fix this issue is to wrap your JSON response in a
<textarea>
tag. The reason for this is iniframe.js
, starting at line 300:So here is where you get your error that reads, "Cannot read property 'value' of
undefined
." Dojo can't find a<textarea>
element in your response, sodoc.getElementsByTagName('textarea')
returns an empty array. The 0th element of an empty array,[]
, isundefined
, and dereferencing it will throw this error.