I am trying to drag and drop an image on a div. The image does not get get dragged onto the div and gives the following error
Uncaught TypeError: Failed to e
It's actually a simple answer.
Your function is returning a string rather than the div
node. appendChild
can only append a node.
For example, if you try to appendChild the string:
var z = 'test satu dua tiga
'; // is a string
document.body.appendChild(z);
The above code will never work. What will work is:
var z = document.createElement('p'); // is a node
z.innerHTML = 'test satu dua tiga';
document.body.appendChild(z);