I know this is a super-old topic but I struggled with the same issue and after combing these forums, trying out various samples of code, nothing worked...until.......
I tried to do this in a different browser. That's right - in Google Chrome I was unable to drag and drop the categories on my product page but I was able to do that using Firefox. Problem solved for now. Hope this saves others from the same frustration I went through.