I'm trying to get the echoed $data which has the class name 'daniweb' in it to return in var temp, however even though $data is echoed, its technically not part of the document. Any ideas? Thanks in advance!
If you paste the contents of the $data var, it might shine some light on this. As for the position of the script, I've moved to placing nearly everything just before the closing </body> tag of the html - far less hassle that way.
however even though $data is echoed, its technically not part of the document
Why not? Whether it's generated by php or 'hard markup' it should still be valid html when it leaves the server - indistingushable form one another.
the order of the script does make difference, if you don't use events to run it. If the script is run before the DOM is created then the elements doesn't exists yet, therefore the method getElementsByClassName() won't find any elements.