You need to wait for document ready before trying to use selectors in JS code. Otherwise, the element(s) you are selecting may not yet exist. pButton might not yet exist when:
What is the purpose of your 300mSec delay? I would guess it is because you didn't use document ready you added an arbitrary delay. If so, of course your delay is a guess that might work on some browsers and networks, but not on others.