When first I tried to read the Harry Potter series, I was put off by the chaos of its moral universe.
The author did not seem to have secure moral bearings, and it seemed that dreadful behaviour was almost causally tolerated or approved.
When looking back across the whole series, I can discern that this was mostly a fault of the 'whodunnit' / detective novel structure, by which vital information is being held back from the reader until near the end.
While this effectively sustains suspense, it does seriously distort the story and its perceived motivations.
JK Rowling's moral universe is a modern one in which kindness and love are (explicitly) the primary virtues; and the greatest evil is cruelty and hatred.
The implicit reason is that a world where people are kind and loving is a happier world than one in which people are cruel and hate-filled.
But there is nothing more to it than that.
JRR Tolkien's moral universe is one in which divine providence is at work.
There is a purpose to his world, and moral evaluations take place relative to that purpose.
Tolkien's is not a world of destiny, since free will is operative. Morally-approved behaviour is when people make difficult choices to support the true purpose of the universe.
In The Hobbit, Bilbo is faced by numerous occasions when he has to choose between selfish and short-term behaviour and behaviour which is clearly 'right' - he is free to choose, and he usually chooses to do what is right. His mission (mostly) succeeds, both by his choices and by several strokes of luck.
At the end Gandalf sums up: "You don't really suppose, do you, that all your adventures and escapes were managed by mere luck, just for your sole benefit? You are a fine person, Mr. Baggins, and I am very fond of you; but you are only quite a little fellow in a wide world after all!"
Here the role of providence, implicitly divine and benign providence, is made explicit. The same thing happens throughout the Lord of the Rings.
By happenstance, I just [yesterday] reread volumes 6 and 7 of Harry Potter, and I couldn't disagree more. It is churlish to expect of Rowling the kind of moral exposition that Tolkien was capable of. I will readily admit, the Rowling expresses herself in the current idiom, which is at variance with the moral tradition that Tolkien mastered, but it is not wholly alien. Tolkien was an incredibly accomplished professor of ancient languages and a medievalist, with the finest education available in England. Rowling is university educated as well, but no one is under the impression that they are intellectual equals.
Nevertheless, Rowling's moral universe really is not quite as far from Tolkien's as Charlton would have it. At first I thought that Charlton had simply not managed to make it through all seven volumes, since the seventh transforms the story entirely. However, scanning on, Charlton does indeed appear to have made it all the way through. However, Charlton missed the many occasions where Providence did play a role, such as Lucius Malfoy's foolish decision to inflict Tom Riddle's diary on Hogwarts.
The biggest mistake of all is to assume that everything Harry Potter does is therefore intended as laudable unless the author somehow indicates otherwise. Even in a children's book, this is not required. Every character in The Lord of the Rings served a purpose, since Tolkien was writing a myth. Characters in Harry Potter usually just act like people, with the usual mix of bad and good.
This especially applies to Dumbledore, who is after all just a man, and as the seventh book shows, prone to all the foolishness and pride that is our lot. It is inapt to compare a mere man to Gandalf, who is a powerful angel that knows and can do a great deal more than he lets on. Dumbledore knows a great deal, but as Aquinas noted, our intellects, even the greatest among us, are just barely intellects compared to those of angels.
I would never place these two works on the same level, but to oppose them so is not borne by the evidence.