It depends on how your server is configured, but the path to the file that you'd use in the exec command usually isn't the same as what you'd use while requesting it via http (which is what a jquery get() does).
I don't understand why in the first code you posted you're using exec(), but in the javascript you're calling getImage.php directly (I'm not saying it's wrong, I'm just curious).
ETA:...or use cron like snakes says above.